I have a line of code that will work differently depending on the datatypes "day" and "1". I believe it is the following although I will check my source code later.
day = day + 1;
Does this make sense? What would the differences be?
NSInteger is a type definition that describes an integer - but it is NOT equivalent to int on 64-bit platforms. You can examine the typedef by cmd-clicking on NSInteger in Xcode. NSInteger is defined as int when building a 32-bit app and as long for 64-bit apps.
NSInteger is just like a traditional int in C. It's a typedef. There are others like NSUInteger , CGFloat , etc. that all are synonyms for primitive types.
NSNumber is a subclass of NSValue that offers a value as any C scalar (numeric) type. It defines a set of methods specifically for setting and accessing the value as a signed or unsigned char , short int , int , long int , long long int , float , or double or as a BOOL .
NSInteger
is a type definition that describes an integer - but it is NOT equivalent to int
on 64-bit platforms.
You can examine the typedef by cmd-clicking on NSInteger
in Xcode.NSInteger
is defined as int
when building a 32-bit app and as long
for 64-bit apps.
Most of the time you can replace int with NSInteger, but there are some things to consider when doing so.
Apple's 64-Bit Transition Guide for Cocoa has some information about that.
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.
If you are working with time values you also could take a look at NSDate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With