[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSComparisonMethods / compare:
From: |
David Ayers |
Subject: |
NSComparisonMethods / compare: |
Date: |
Mon, 29 Dec 2008 19:54:23 +0100 |
Hello,
I just noticed that new compatibility methods were added to -base which
use the compare: method in their NSObject implementation.
>From memory using compare: on "incompatible" types is undefined
behavior. I.e. a compare: method may assume that the the argument is of
"compatible" class and may reference instance variables of the parameter
directly. In fact our NSString implementation assumes that.
I haven't found any documentation about this requirement, and I'm not
sure it exists on Cocoa.
But I wonder whether we should document this requirement (i.e. that it's
the users responsibility to insure that the compared objects are
"compatible", since I keep running into such issues when people use
these values and compare NSStrings with NSNumbers or NSNull instances
resulting in invalid memory access.
Cheers,
David
PS: We deprecated NSObject's compare: back in 2003, would anyone mind if
I remove the declaration in our NSObject.h for the following release? [I
would wait another stable release cycle before removing the
implementation.] Maybe the same should be done for the other deprecated
methods.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- NSComparisonMethods / compare:,
David Ayers <=