Reputation: 13258
I have a NSTimeInterval
and I have a JSON value 1257808000000
.
I do this:
NSTimeInterval *myTimestamp = [myJSON objectForKey:@"thetimestamp"];
But I get this warning:
Incompatible pointer types initializing 'NSTimeInterval *' (aka 'double *')
with an expression of type 'id'
How can I solve this problem?
Best Regards.
Upvotes: 6
Views: 5123
Reputation: 46037
NSTimeInterval is actually a double value. It's not an object.
NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue];
Upvotes: 16
Reputation: 6280
if your object for key @"thetimestamp"
is a NSString
or NSNumber
then
NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue];
Upvotes: 1
Reputation: 4159
Try
NSTimeInterval *myTimestamp = (NSTimeInterval*)[myJSON objectForKey:@"thetimestamp"];
Upvotes: -4