I'm querying a NSDictionary for a value. Because I got problems I printed the object. It shows me the following:
<CFString 0x5d33630 [0x26af380]>{contents = "myDictionaryItem"} = <CFNumber 0x5d58940 [0x26af380]>{value = +1286301600, type = kCFNumberSInt64Type}
So it is of type signed 64 bit integer. So I tried to extract the value like this
NSString *myString = [NSString stringWithFormat:@"%qi", [myDictionary objectForKey:@"myDictionaryItem"]];
That gives me a value but the value is not the one in the dictionary.
I also tried this
long long my64bitsignedIntegerValue = (long long)[myDictionary objectForKey:@"myDictionaryItem"];
but I get the warning Cast from pointer to integer of different size
. That doesn't work because stringWithFormat
is returning a value of type id
. I found this post where id
is of type UInt32
. And a signed 64 bit integer is not unsigned 32 bit integer, so I get this warning. If I ignore the warning, the value is still wrong.
The value I would like to have is e.g. 1286301600. A signed integer (−2.147.483.648 to 2.147.483.647) should do the thing I want. I don't understand why Cocoa is trying to make a 64 bit signed Integer.
How can I extract the 64 bit signed integer of the dictionary and use it as a variable?