• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I store a float as a value in NSDictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >How do I store a float as a value in NSDictionary? (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: Redirect stderr to NSTextView
  • Next by Date: Re: How do I store a float as a value in NSDictionary?
  • Previous by thread: How do I store a float as a value in NSDictionary?
  • Next by thread: Re: How do I store a float as a value in NSDictionary?
  • Index(es):
    • Date
    • Thread