Reputation: 621
Is there is no needs of declaring NSInteger using the alloc and initialise keyword? and why?
I was trying doing NSInteger *choice = [[NSInteger alloc] init]; while I found direct assignment
Upvotes: 1
Views: 10596
Reputation: 8745
NSInteger is just typedef of int or long (depends on platform)
So you can initialize something like that
NSInteger i = 10;
Quote from SDK documentation
NSInteger Used to describe an integer.
typedef long NSInteger;
When building 32-bit applications, NSInteger is a 32-bit integer. A 64-bit application treats NSInteger as a 64-bit integer.
Upvotes: 3
Reputation: 89519
NSInteger is not an Objective-C object. It's a datatype (much like C's int
or char
types). You do not need to call "alloc
" (to explicitly allocate memory space) for it.
You can read up on the other Objective-C data types (like NSRange
, which you'll use a lot of once you get into NSString objects) in this Apple documentation.
Upvotes: 1