Advertise with us

In iOS what we prefer NSInteger or int

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?

Last updated:12/9/2015 11:36:09 PM

1 Answers

Tarun Kumar
Tarun Kumar

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.

Answer