On Jul 14, 2014, at 3:44 AM, Uli Kusterer <witness.of.teacht...@gmx.net> wrote:

> NSNumber is more complicated to use (constant calls to integerValue and 
> valueWithInteger: etc. to actually work with them) and carries a bit more 
> overhead (it creates a new NSObject subclass on the heap every time

“Every time" hasn’t been true for years (since 10.7?) NSNumbers representing 
“small enough” integers are represented as tagged pointers and don’t cause any 
heap allocation at all. 

The exact meaning of “small enough” is an implementation detail (and differs 
greatly between 32-bit and 64-bit) but in practice, integers up to ±1000 should 
be cheap, I believe.

But I agree about NSNumbers being more complicated. The only time you need to 
use an NSNumber is if you want to stick a number into a collection or otherwise 
need to treat it as an object.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to