On Apr 7, 2008, at 11:12 AM, glenn andreas wrote:

Right, but by having dummy placeholders, they can later rename "_extra" to "_something", and if you have an ivar named "_something" there will be problems. (For that matter, they could also change existing ivar names as well).

No, the breakage doesn't occur at runtime, rather at compile time. And it results in a simple compile error that's very easy to fix.

In the case of renaming _extra to _something, no.

For example, an OS update comes out where a framework has a change like this. Customer upgrades the OS. There is KVC based access to [obj setValue: newValue forKey: @"_something"] (either in your code, or in the updated framework - perhaps in NIB loading). Suddenly there is a collision - KVC will change one of them, even though the hard-coded access methods will still be grabbing their own respective versions.

There is already the possibility of KVC collisions regardless of how you name your iVars.

Consider...

NSBaseClass, and MyClass derived from it.

Targetting 10.4, MyClass has an iVar named mImportantProperty (using m prefix here only for argument's sake), and accessors - setImportantProperty:, -importantProperty.

10.5 comes along and NSBaseClass gets a private iVar named _importantProperty, and the framework code uses KVC to access this property (perhaps through the private accessors - _setImportantProperty:, -_importantProperty.)

My code has violated the don't use the _ prefix for your method names rule.

My code hasn't used the don't use the _ prefix on my iVar names rule/ suggestion/convention.

Yet, I still have the KVC conflict. (And yes, it will probably be a pain in the neck to track down.)

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 [EMAIL PROTECTED]

Reply via email to