• 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: NSNumber is completely broken
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumber is completely broken


  • Subject: Re: NSNumber is completely broken
  • From: Todd Blanchard <email@hidden>
  • Date: Thu, 26 May 2005 06:42:58 -0700


On May 26, 2005, at 12:45 AM, Gerriet M. Denkmann wrote:


NSNumber is a subclass of NSValue but does not behave like one.
It has _less_ functionality than its superclass (e.g. objCType),
and it uses _less_ storage:

Ah, premature optimization I'd say.  Make it fast rather than right.  I would say the cost of this little optimization is much too high as it makes writing bridges much more difficult.

Or you should use NSValue and "- (id)initWithBytes:(const void *)value objCType:(const char *)type"

Great, how do I get valueForKeyPath: to start returning NSValues?

NSNumber with double uses 16 bytes, whereas NSValue uses 32.
NSNumber with BOOL uses 0 bytes, whereas NSValue uses 16.
So for storing 10 million BOOLs this makes quite a difference.
(All this tested on 10.4.1)

If you need that many bools you should be using a bit vector.

Also NSValue seems to be slightly slower.

I would prefer slow and right to fast and wrong.  
Thanks for the info.  I think I will end up posing NSNumber to restore NSValue semantics.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: NSNumber is completely broken (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: How should I do with tableview ?
  • Next by Date: Re: Function calling
  • Previous by thread: Re: NSNumber is completely broken
  • Next by thread: Re: NSNumber is completely broken
  • Index(es):
    • Date
    • Thread