Re: Tell which type is in NSValue?
Re: Tell which type is in NSValue?
- Subject: Re: Tell which type is in NSValue?
- From: Graham Cox <email@hidden>
- Date: Wed, 5 Aug 2009 21:13:13 +1000
On 05/08/2009, at 6:27 PM, Alastair Houghton wrote:
Usually when you're using NSValue, you already know what type you're
dealing with. If you have a situation where you need to distinguish
between several different things, you might be better off making
some wrapper classes (or maybe subclasses of NSValue, which is how
NSNumber works).
Not only that, but note this from the docs for [NSNumber objCType]:
"Special Considerations The returned type does not necessarily match
the method the receiver was created with."
This makes it very hard to preserve type information using NSNumbers -
integers and floats usually end up converted internally to doubles, I
found. The same warning does not appear to be applied to NSValue
however. If type is of critical importance though, I'd store it
explicitly in an object of your own devising.
--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