Brad Larson's answer is absolutely right. To tell you more about this, you must explicitly "wrap" the types of numbers without objects (for example, int , unsigned int , double , float , BOOL , etc.) In NSNumber when working with everything that an object expects.
On the other hand, some mechanisms in Objective-C, such as Key-Value Coding (KVC), will automatically make this packaging for you.
For example, if you have an int type @property called intProperty and you call the NSObject (NSKeyValueCoding) valueForKey: , for example [ someObject valueForKey:@"intProperty" ] , the result of the return is NSNumber * , NOT an int .
Honestly, I donβt need to switch between communicating with objects and non-object types (especially struct and enum s!) In Objective-C. I would prefer that everything be seen as an object, but maybe it's just me. :)
source share