I have an unsigned 63-bit value that I store in a UInt64 that I need to convert to an AnyObject so I can store it in a NSDictionary. I have converted it to an Int, but that will only store it on a 64-bit system, on a 32-bit system an Int is still 32-bit and I get an error. Since neither UInt64 nor Int64 can be cast to an AnyObject, I cannot use them. Do I have better options than NSNumber(unsignedlonglong: value)
Asked
Active
Viewed 308 times
1

niklassaers
- 8,480
- 20
- 99
- 146
-
"Do I have better options than NSNumber(unsignedlonglong: value)" Better how? – Tristan Burnside Mar 01 '16 at 11:03
-
3There is no better option, compare http://stackoverflow.com/questions/28177435/storing-int64-in-userdefaults. – Martin R Mar 01 '16 at 11:03
-
Sorry for being vague, with "better" I meant more Swift-native less Cocoa-dependant, but since it's going into an NSDictionary, this is probably not relevant – niklassaers Mar 01 '16 at 11:10
-
more Swift-native less Cocoa-dependant .... so why you use the NSDictionary as 'storage' container? – user3441734 Mar 01 '16 at 11:29
-
Even an Int is converted to NSNumber when you put it into an NSDictionary, the only difference is that the compiler creates the code for you. – Martin R Mar 01 '16 at 11:30
-
Thanks guys, I'll stick with NSNumber then :-) – niklassaers Mar 01 '16 at 12:10