I have an iOS 4 project using Core Data. When I design the Core Data Model, the attributes have Integer 64
, Integer 32
, Integer 16
, Decimal
, Double
, Float
, and Boolean
.
But in the generated NSManagedObject
subclasses, they are all NSNumber*
. So when I use it, how can I tell if that NSNumber
is a long
, a double
, a float
, or a BOOL
?
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:myManagedObjectContext];
NSAttributeDescription *attribute = [[entity attributesByName] objectForKey:@"myAttribute"];
if ([attribute attributeType] == NSInteger32AttributeType) {
// We have an Integer32
// ...
}
Check the NSAttributeDescription.h
header for other valid attribute types besides NSInteger32AttributeType
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With