Subscribe ( )

iPhone Programming Tutorials

 

Forum

You must be logged in to post Login Register

Search 

NSInteger vs NSNumber vs int

User Post

2:53 pm
October 6, 2008


Noob

London

posts 2

1

It may seem trivial but please let me ask what is the real difference between using either on the iPhone.

I have read about NSInteger to be the next step for 64 bit architecture which probably has nothing to do with the iPhone and my app but of course I wonder why this difference. Shoudn't int be a native objective C element without any extra need?

And what about NSNumber, i understand I may need it as some Cocoa methods ask for object but what is the performance implications on the iPhone?

Should I try to use int in such a memory scarce system?

Thanks for the time.

12:11 pm
October 10, 2008


Neil

iCoder

North Wales, UK

posts 6

2

As far as the iPhone is concerned, NSInteger and int are interchangable. Take a look at the definition in NSObjCRuntime.h:

#typedef int NSInteger;
#typedef unsigned int NSUInteger;

Obviously from this, NSInteger and int are one and the same.

NSNumber is very different as it provides a way for holding a value as any numeric type, not just ints, but char, short int, long int, long long int, float, double and BOOL. It's your quintessential Swiss Army knife of numeric types. 

12:55 pm
October 17, 2008


Noob

London

posts 2

3

Thanks so much for the clarification.


About the iCodeBlog forum

Currently Online:

2 Guests

Maximum Online: 19

Forums:

Groups: 2

Forums: 6

Topics: 144

Posts: 468

Members:

There are 259 members

There are 1 guests


Brandon has made 79 posts

Top Posters:

bobcubsfan - 44

crazyiez - 30

Uhu - 17

VertigoSol - 17

Nick - 15

Administrator: Brandon | Moderators: VertigoSol


© - Version 3.1.4 (Build 357)  

Share and Enjoy: