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: Ken Thomases <email@hidden>
- Date: Sun, 23 Feb 2014 04:04:02 -0600
On Feb 23, 2014, at 3:30 AM, email@hidden wrote:
> 3. For any given object subclass (of which there may be many) I want -objCType to be constant.
>
> I think that NSNumber does all of the above. Ken believes that 3. is in doubt.
> If this proves to be the case then I will have to go down the custom class route.
I don't know why that should be for "any given object subclass" rather than for "any given value". Also, I don't have to prove it may differ. I only have to point out that there's no guarantee that it will be constant. No amount of empiricism can establish that guarantee. Without a design contract, things may always change at any time.
As it happens, it's easy to prove:
[[NSNumber numberWithChar:-5] objCType] -> "c"
[[NSNumber numberWithShort:-5] objCType] -> "s"
[[NSNumber numberWithInt:-5] objCType] -> "i"
[[NSNumber numberWithLong:-5] objCType] -> "q"
All of these number objects compare equal and will thus be interchangeable as dictionary keys in Cocoa. But they won't have the same representation in your scheme and so will fail to compare equal in Mono.
Tested on OS X 10.6.8. Results may differ on other versions of the OS.
-Ken
_______________________________________________
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