I want to have an Entity property in Core Data be a 64-bit integer. Since the model is going to run on iOS, and as far as I know these devices are not 64-bit, I figured that NSNumber was the way to go (core data gives you the option of objects or scalar properties for primitive types).
I’m assuming that NSNumber will internally take care of keeping track of a suitable representation for 64 bits.
Now, I need to subtract 1 from this “64 bit” property in my entity at some point (in case you didn’t guess, the 64 bit property is the max_id parameter in the Twitter API), but to do so, I first need to unbox the number inside the NSNumber property.
So should i get the intValue? longValue? unsignedIntValue? unsignedLongValue? long long? which one?
Since you already know the type (64 bit integer), you don’t need to check for it.
To get a 64 bit integer out of a NSNumber, do one of the following:
In order to just add one to it, you can use something like this:
Note that iOS does have 64 bit data types like
int64_tandNSInteger.EDIT:
If the only reason that you are using
NSNumberis to store the 64 bit integer, you can just declare the property like this in your model subclass and skip the unboxing/boxing altogether:Note that core data does this by default if you select the Use scalar properties for primitive data types option of the Create NSManagedObject Subclass feature.