Re: setting a BOOL var in a NSManagedObject
Re: setting a BOOL var in a NSManagedObject
- Subject: Re: setting a BOOL var in a NSManagedObject
- From: Jean-Daniel Dupas <email@hidden>
- Date: Wed, 2 Jan 2008 17:14:04 +0100
Le 2 janv. 08 à 17:05, Steven Crosley a écrit :
I have a subclass of a NSManagedObject where one of the attributes
is a Boolean type. My method to set the value of this attribute
looks like this:
- (void)setActive:(BOOL)flag
{
[self willChangeValueForKey:@"active"];
[self setPrimitiveValue:flag forKey:@"active"];
[self didChangeValueForKey:@"active"];
}
However, I'm getting the warning message below:
warning: passing argument 1 of 'setPrimitiveValue:forKey:' makes
pointer from integer without a cast
It doesn't appear to set it when I run the app and I get the
following error message in the logs:
setNilValueForKey]: instance of entity Test could not set nil as the
value for the key active.
Any Help would be appreciated.
Thanks!
Steven
setPrimitiveValue: expect an object as argument. BOOL is not a valid
Obj-C object, it is a base type.
You should use:
[self setPrimitiveValue:[NSNumber numberWithBool:flag]
forKey:@"active"];
_______________________________________________
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