我有一个使用Core Data的iOS 4项目.当我设计的核心数据模型,属性有Integer 64,Integer 32,Integer 16,Decimal,Double,Float,和Boolean.
但是在生成的NSManagedObject子类中,它们都是NSNumber*.所以当我使用它时,如何判断它NSNumber是a long,a double,a float还是a BOOL?
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:myManagedObjectContext];
NSAttributeDescription *attribute = [[entity attributesByName] objectForKey:@"myAttribute"];
if ([attribute attributeType] == NSInteger32AttributeType) {
// We have an Integer32
// ...
}
Run Code Online (Sandbox Code Playgroud)
检查NSAttributeDescription.h标题以获取其他有效的属性类型NSInteger32AttributeType.
| 归档时间: |
|
| 查看次数: |
3668 次 |
| 最近记录: |