Re: Getting rid of primitive accessor warnings
Re: Getting rid of primitive accessor warnings
- Subject: Re: Getting rid of primitive accessor warnings
- From: Keary Suska <email@hidden>
- Date: Thu, 01 Nov 2012 09:46:42 -0600
On Nov 1, 2012, at 9:24 AM, Fritz Anderson wrote:
> On 1 Nov 2012, at 9:55 AM, Keary Suska <email@hidden> wrote:
>
>> This is normal and expected, as it is a default warning (at least on OS X). What is the problem, exactly? There is no value whatsoever that I know of to declare primitive accessors if you don't intend to implement them. Furthermore, you shouldn't need to declare primitive accessors at all as they should not be publicly called. Or in other terms, exposing them is probably a code smell. In any case, Core Data synthesizes them for you anyway….
>
> I haven't needed to call primitive accessors in a while, but the fact that Core Data synthesizes them at run time doesn't mean the compiler knows that the methods exist. Last I looked, you had to declare a category containing the primitives the class's own code (not the general public's) needed to call, or the compiler would complain as the OP said.
That is an important distinction that should be included. I didn't talk about *private* access as the warnings the OP was complaining about have to do with methods declared for (ostensibly) "public" access (i.e. not as a category or extension).
> Declare the primitive accessors so the compiler won't complain about their use.
>
> Declare them in a category so the compiler won't complain that the main implementation doesn't contain their definitions.
>
> It would be neat if clang inferred the existence of primitives from the presence of dynamic properties in an NSManagedObject subclass, so declaration wouldn't be necessary, but I haven't tried it.
IMHO it seems like a lot of effort for infrequent cases when you can just use setPrimitiveValue:forKey...
Keary Suska
Esoteritech, Inc.
_______________________________________________
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