Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Getting rid of primitive accessor warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting rid of primitive accessor warnings



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.

Takeaway:

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.

	— F

--
Fritz Anderson -- Xcode 4 Unleashed: 4.5 supplement in the works -- <http://x4u.manoverboard.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


References: 
 >Re: Getting rid of primitive accessor warnings (From: Keary Suska <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.