1. When you need to use a variable of type int, you can use int or Nsinteger as a program written C, but it is more recommended that Nsinteger be used, as this will not be considered 32-bit or 64-bit for the device.
2.NSUInteger is unsigned, that is, there are no negative numbers, and the Nsinteger is signed.
3. It is said that since all of these basic types are nsinteger, why should there be nsnumber? Their functions are, of course, different.
Nsinteger is the underlying type, but NSNumber is a class. If you want to store a numeric value, it is not possible to use Nsinteger directly, such as in an array: Nsarray*array = [[Nsarray alloc]init];
[Array addobject:3];//compile error This will cause a compilation error, because the nsarray inside needs to be a class, but ' 3 ' is not. This time need to use Nsnumber:nsarray*array = [[Nsarray alloc]init];
[Array Addobject:[nsnumber numberwithint:3];
+ (NSNumber *) Numberwithchar: (char) value; Cocoa provides a basic data type that is packaged (that is, implemented as an object) by the NSNumber class.
For example, the following creation method:
+ (NSNumber *) Numberwithint: (int) value;
+ (NSNumber *) Numberwithfloat: (float) value;
+ (NSNumber *) Numberwithbool: (BOOL) value;
Once the base type data is encapsulated in NSNumber, it can be retrieved by using the following instance method:
-(char) charvalue;
-(int) intvalue;
-(float) floatvalue;
-(BOOL) boolvalue;
-(NSString *) stringvalue;
"IOS" Int,nsinteger,nsuinteger,nsnumber