The use of int and long is confusing today.
In C, the number of bytes of int and long is the same as that of the operating system pointer.
However, in C language, the length of long is always greater than or equal to int.
In objective-C, nsinteger is always recommended in Apple's official documentation.
What is the difference between it and Int? stackoverflow gives the answer.
In Apple's API implementation, nsinteger is an encapsulation that identifies the number of digits in the current operating system and automatically returns the maximum type.
The defined code 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 to use nsinteger when you don't know what kind of processor architecture your code might run on, so you may for some reason want the largest possible
Int type, which on 32 bit systems is just
Int, while on a 64-bit system it's a long.
When you don't know what type your operating system is, you usually want to use nsinteger, so maybe you want your int type range to be as large as possible, using nsinteger, in a 32-bit system, nsinteger is an int, that is, 32-bit. In a 64-bit system, nsinteger is 64-bit.