Re: NSNumber : method to return pointer to represented value
Re: NSNumber : method to return pointer to represented value
- Subject: Re: NSNumber : method to return pointer to represented value
- From: Uli Kusterer <email@hidden>
- Date: Sun, 23 Feb 2014 18:01:38 +0100
On 23 Feb 2014, at 14:15, Graham Cox <email@hidden> wrote:
> On 23 Feb 2014, at 11:08 pm, email@hidden wrote:
>
>>> 1(int) and 1(float) can be represented by the same NSNumber object perfectly legally.
>> Is that true?
>
> I said "can be", not "is". Certainly my observation in the past was that NSNumber stored, as an int, a float that could be represented purely by an int. This was probably in the 10.4/10.5 timeframe or so, which caused me to create a class that stored the original data type as well as a value. It may be that the implementation has changed since then - certainly tagged pointers weren't used - and it's actually always a separate object now where -objCType doesn't ever change. But that just shows that the implementation can change in a way that would affect your scheme, and could again.
Graham is right. Similarly, in ye olde days, NSNumber numberWithBool: used to return NSNumbers containing the int 1 or 0. These days, they’re short-circuited to actually return kCFBooleanTrue and kCFBooleanFalse. It has changed, and might change again.
Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de
_______________________________________________
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