On Jul 10, 2008, at 11:19 AM, glenn andreas wrote:

The problem is that while when you recompile you'll see the conflict, for existing users (who won't be compiling from source), if they use KVC they'll have the problem.

@interface NSFoo {
        id _reserved;
}
@end
@interface MyFoo: NSFoo {
        float _value;
}
@end

And OS X+1 comes out with:

@interface NSFoo {
        int _value;
}
@end

Any of your code that used _value (like, say, for bindings) could suddenly break for users of OS X N+ 1 (since they won't be compiling from source to see what is going on).


Granted, it's rare that this happens, but from time to time reserved fields do get converted to something used. And lets face it, if you hear "it works fine on OS X N, but breaks on OS X N+1", "ivar collision" isn't the first thing you'll think about to try to track down the problem...

Worse, this could actually happen on an OS X N+ 0.1 release and the headers wouldn't get updated so you won't even have the safety net of seeing compiler errors. Similarly, if you target the OS X N SDK, you won't see the new headers either.


"Haven't run into such problems" != "Such problems don't happen"


I definitely got burned by this myself a few years back (when the NSAnimation API was added). I didn't use that class at all, but got very strange runtime issues with an NSCell subclass of mine. One of the cell's ivars name collided with NSAnimation. And, in code like this:

[[self cell] foo];

Since, [self cell] returns id, it ended up thinking that the return object was actually an NSAnimation instance and not my cell.


From that point onwards, I've renamed all my classes, ivars, binding names, keys, etc. to use a custom prefix/suffix of II (company name).

Details of this approach can be found in the archives.
___________________________________________________________
Ricky A. Sharp         mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

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