On Feb 16, 2010, at 2:38 PM, Steven Degutis wrote:

> Boolean attributes in Core Data are not actually of type BOOL but rather 
> NSNumber. Thus, your NO value is interpreted as nil (since nil == 0 == NO) 
> and you're setting your attribute to nil. If the attribute is required, then 
> nil is not a valid value, and you will get a validation error. Next time, if 
> you look at the header of your file, it tells you what types you should use 
> as arguments to methods, and what types to expect as return values.

Thanks. Silly me, I thought that when the docs said that a BOOL was YES or NO 
then those were the values to use. I did some research on Key-Value coding and 
then was able to get the code to work by modifying it to the following:

        NSNumber *myBoolNumber = [NSNumber numberWithBool:NO];
        [myNewObject setMyBooleanAttribute: myBoolNumber];
> 
> Steven Degutis
> Software Engineer
> Big Nerd Ranch, Inc.
> http://www.bignerdranch.com/
> 
> On Tue, Feb 16, 2010 at 5:35 PM, Lynn Barton <lynnbar...@mac.com> wrote:
> Why does my Core Data app give me a validation error message, when quitting 
> the app, if the following code is used? I am importing some legacy data to 
> set 5 string attributes of an object, but using this code to set the one BOOL 
> attribute. In my model, myBooleanAttribute has a default value of NO, and the 
> legacy data does not include this attribute, so I can avoid the validation 
> error by omitting the following code, but I would like to know why it causes 
> errors.
> 
> [myNewObject setMyBooleanAttribute: NO];
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com
> 
> This email sent to steven.degu...@gmail.com
> 
> 
> 
> -- 
> Steven Degutis
> http://www.thoughtfultree.com/
> http://www.degutis.org/

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to