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: Graham Cox <email@hidden>
- Date: Mon, 24 Feb 2014 00:15:01 +1100
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.
> The second provides some support for the idea that the NSNumber private subclasses do indeed return an invariant -objCType.
Maybe they do - today. But they are not required to do so, and have not done so in the past.
How many types do you need to support anyway? What about my string idea? Either that or a custom class would actually require very little effort - probably less than the typing in this discussion so far anyway!
--Graham
_______________________________________________
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