开发者

Simple Question about Core Data

I using the project named coredatabooks from apple developer examples.

#import 

@interface Book : NSManagedObject  
{
}

@property (nonatomic, retain) NSNumber *active;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *author;
@property (nonatomic, retain) NSDate *copyright;

@end

I need to use a bool object, but I don't know how to implement it in my class.. I'm using 开发者_JAVA技巧right now NSNumber, using an integer (0, 1) but is not a Bool... maybe it will be more correct to use this ...

@property (nonatomic, retain) bool active;

but is not working.


You can still use an NSNumber, but pack it from a bool:

[NSNumber numberWithBool: myBool];

and unpack it to a bool:

[myNSNumber boolValue];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜