Core Data and BOOL setup

Posted by John Valen on Stack Overflow See other posts from Stack Overflow or by John Valen
Published on 2010-05-17T15:46:31Z Indexed on 2010/05/17 15:50 UTC
Read the original article Hit count: 256

Filed under:
|
|

I am working on an app that uses Core Data as its backend for managing SQLite records. I have everything working with strings and numbers, but have just tried adding BOOL fields and can't seem to get things to work.

In the .xcdatamodel, I have added a field to my object called isCurrentlyForSale which is not Optional, not Transient, and not Indexed. The attribute's type is set to Boolean with default value NO.

When I created the class files from the data model, the boilerplate code added for this property in the .h header was:

@property (nonatomic, retain) NSNumber * isCurrentlyForSale;

along with the

@dynamic isCurrentlyForSale;

in the .m implementation file.

I've always worked with booleans as simple BOOLs. I've read that I could use NSNumber's numberWithBool and boolValue methods, but this seems like an aweful lot of extra code for something so simple.

Can the @property in the header be changed to a simple BOOL? If so is there anything to watch out for?

Thanks -John

© Stack Overflow or respective owner

Related posts about core-data

Related posts about iphone