46th Day As An iOS Developer With No Experience

What's up everyone?! I reviewed some of my posts last night, and I realized that there are some errors in my grammar. Haha! I got no time to correct those, I don't care, as long as I deliver my message correctly and everyone can understand my tutorial clearly.

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, use NSInteger, NSUInteger or int.
Pretty 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.

So there you go folks. The difference between NSNumber and NSInteger. :)

Post a Comment