Re: Comparing results of @encode
Re: Comparing results of @encode
- Subject: Re: Comparing results of @encode
- From: Graham Cox <email@hidden>
- Date: Mon, 27 Oct 2008 09:23:36 +1100
On 27 Oct 2008, at 3:28 am, Michael Ash wrote:
For this particular case, it would be roughly just as fast and more
reliable to do something like:
if([myNumber objCType][0] == 'f')
The type encoding characters are documented here:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_13_section_9.html
Cool, thanks.
Also note that NSNumber is smart enough to automatically convert its
internal representation to whatever you ask for. So for example if
'double' encompasses every value you might need, then it's safe to
simply use [myNumber doubleValue] even if you created it as an int or
float value.
Understood, though in fact that's a slight hindrance in my case. Given
an arbitrary NSNumber, I need to know its type - int, bool or float at
the very least. If it gets converted to some other representation
internally, it means that I could find types "mutating" from float to
double, say.
Still, I have it working and it seems to be OK for now. I can live
with float->double for example, though bool->int would be a problem.
However it seems that doesn't occur.
thanks,
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