Re: How do I store a float as a value in NSDictionary?
Re: How do I store a float as a value in NSDictionary?
- Subject: Re: How do I store a float as a value in NSDictionary?
- From: Wade Tregaskis <email@hidden>
- Date: Sun, 20 Jun 2004 22:16:44 +1000
I understand that setObject should actually be passed an object, not a
float or int, so should I convert the float to an object, say
NSNumber? Or is there another solution?
No, that's about it. All Cocoa collection classes require a valid
object, since they will at the very least retain/release it (and most
likely use hash, too, particularly in the case of a dictionary), so you
can't just type cast or anything like that.
If you're storing floats and doing a lot of computation with them, it's
orders of magnitude faster to use an equivalent STL class (or write
your own if you don't want to use ObjC++). If you're just storing
preferences or outputs or whatever, the overhead isn't usually too bad.
Wade Tregaskis (aim: wadetregaskis)
-- Sed quis custodiet ipsos custodes?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.