Reputation: 285
I'm creating an object that will have two integers (or NSNumber
s) and an NSDate
as ivars. This object will be in an NSMutableArray
. To my knowledge, we cannot put primative integers in an NSMutableArray
, but will my object work with int
s? The reason I don't want to use NSNumber
s is because these will have to be mutable, and I don't really want to create a new NSNumber
everytime.
Also, will using int
s create problems with iphone architecture differences?
Upvotes: 2
Views: 2023
Reputation: 20184
1) You can safely use ints as ivars because they are wrapped in another object. NSNumber is just a Cocoa class wrapper for the different numeric types.
2)To be safe, you could use NSUInteger
, which is typedef
ed like this:
#if __LP64__ || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
So you will get the correct type for the current architecture.
Upvotes: 2