NSNumber vs Int

后端 未结 3 1236
太阳男子
太阳男子 2020-12-19 01:22

If integers cannot be written to a dictionary and then to a .plist, but NSNumbers can is it better to use NSNumbers throughout the app, rather than needing to convert every-

3条回答
  •  情深已故
    2020-12-19 01:57

    NSNumber is object inherited from NSValue wrapper object.

    int is not object.

    if use NSNumber u can get more and more function to utilize with them.

    http://developer..com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html

    NSNumber is a class that helps you to store numeric types as object. It has methods to convert between different types and methods to retrieve a string representation of your numeric value. If you use a variable day of type NSNumber* the way you did in your example, you are not modifying the value of day but its memory address.

提交回复
热议问题