The difference between int and Nsinteger in objective-c

Source: Internet
Author: User

int is a static type

Nsinteger is a dynamic type

Apple's official recommendation is to use Nsinteger, because in Apple's API implementation, Nsinteger is a package that recognizes the number of bits in the current operating system and automatically returns the largest type.

The code defined is similar to the following:

#if __lp64__ | | target_os_embedded | | Target_os_iphone | | Target_os_win32 | | Ns_build_32_like_64

typedef LONG nsinteger;

typedef unsigned long nsuinteger;

#else

typedef INT nsinteger;

typedef unsigned int nsuinteger;

#endif

You usually want the Nsinteger when you don ' t know what kind of processor architecture your code might run on, so Y OU may for some reason want the largest possible int type, which on + bit systems is just an int, while on a 64-b IT system it ' s a long.

The difference between int and Nsinteger in objective-c

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.