Re: Validation error after setting the value of a boolean attribute
Re: Validation error after setting the value of a boolean attribute
- Subject: Re: Validation error after setting the value of a boolean attribute
- From: Steven Degutis <email@hidden>
- Date: Tue, 16 Feb 2010 17:38:39 -0500
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.
Steven Degutis
Software Engineer
Big Nerd Ranch, Inc.
http://www.bignerdranch.com/
On Tue, Feb 16, 2010 at 5:35 PM, Lynn Barton <email@hidden> 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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden