views:

719

answers:

3

I have created a BOOL attribute in my Core Data entity called "useSystem". Additionally in order for me to get/set the data I have created an object, however whenever I try to set the synthesized BOOL I get a bus error. This is my code:

@property (nonatomic) const BOOL useSystem;

So I'm doing

[object setUseSystem:YES];

And immediately I get the bus error. Can anyone help?

+3  A: 

Use [NSNumber numberWithBool:YES]

Eimantas
and [[Entity isBool] boolValue] to read it.
RickiG
+1  A: 

It is probably better style to use NSNumber as the property type actually. This is also what happens when you use the model editor in xcode to add a boolean attribute to an entity. There is 'auto-boxing' going on but I always seem to have less troubles when I just use the higher level Objective-C types and wrappers like NSNumber.

St3fan
A: 

This should work if you declare the method explicitly but it might not work with @synthesize. Seems like I've done this before, but maybe I just used the BOOL with no mutator method. (You can use @property without @synthesize if you define the method(s) that @property declares.)

Nimrod