• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: setting a BOOL var in a NSManagedObject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >setting a BOOL var in a NSManagedObject (From: Steven Crosley <email@hidden>)

  • Prev by Date: setting a BOOL var in a NSManagedObject
  • Next by Date: Re: setting a BOOL var in a NSManagedObject
  • Previous by thread: setting a BOOL var in a NSManagedObject
  • Next by thread: Re: setting a BOOL var in a NSManagedObject
  • Index(es):
    • Date
    • Thread