On Jan 13, 2010, at 8:39 AM, Richard Somers wrote: > On Jan 13, 2010, at 1:17 AM, Kyle Sluder wrote: > >> This code cannot generate that error because it doesn't send any >> messages. You need to post the code to which the error actually >> refers. > > This works. > > @property (nonatomic, retain) NSNumber *selected; > > if ([[self selected] boolValue]) { ... } > > This produces error "unrecognized selector sent to instance". > > @property (nonatomic, retain, getter=isSelected) NSNumber *selected; > > if ([[self isSelected] boolValue]) { … }
Assuming you are using @dynamic and relying on Core Data to generate the accessors for you, that isn’t going to work. Core Data doesn’t support the isPropertyName getter style. This style is typically used for non-object BOOL values. If you use it for an NSNumber attribute, you run the risk of someone familiar with the pattern assuming it is a BOOL property and writing if ([managedObject isSelected]) { } which will of course be be true whenever the property is non-nil, no regardless of the actual value. If you want or need to use custom getters/setters, you’ll have to provide your own accessors rather than relying on the @dynamic generated ones. - Jim_______________________________________________ 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