Today I used AFNetworking again. But what I'm going to discuss today is the NSNumber in iOS.
NSNumber is probably the ugliest part of Objective-C - myCTO
Base on what I've read on the internet, okay, let's talk about the NSInterger first. NSInteger is basically an int. Everyone knows that int, right? Now, NSNumber is simply an object. According to the user named: 'nepster' on Stackoverflow:
If you need to store a number somewhere, use NSNumber. If you're doing calculations, loops, etc, usePretty straight forward answer. Talking again about the NSNumber, it 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.NSInteger , NSUInteger or int.
So there you go folks. The difference between NSNumber and NSInteger. :)
Post a Comment