Home > DeveloperSection > Forums > In iOS what we prefer NSInteger or int
Glen Martin
Glen Martin

Total Post:27

Points:191
Posted on    December-08-2015 10:32 PM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 210  View(s)
Rate this:

Can any one tell me the benefit to using the NS types our the built-ins. and which we prefer and why?

Is int and NSInteger has the same width on 32/64 bit platforms?



Tarun Kumar

Total Post:210

Points:1614
Supported
Posted on    December-09-2015 11:36 PM

In my according NSInteger have all the features of safe architecture versions of the corresponding C types, basically its size changes depending on the architecture. and NSInteger is guaranteed to hold any valid pointer for the current architecture.

Apple also recommends that you use these to work with OS-X and onwards, and Apple's APIs will use them, so it is definitely a good idea to get into the habit of using them. It require a little more typing, but it is a part from that it doesn't seem to be any reason not to use them.


Don't want to miss updates? Please click the below button!

Follow MindStick