Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTimeInterval -> incompatible pointer types

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.

like image 735
Tim Avatar asked Feb 01 '11 09:02

Tim


2 Answers

NSTimeInterval is actually a double value. It's not an object.

NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue];
like image 139
taskinoor Avatar answered Nov 08 '22 06:11

taskinoor


if your object for key @"thetimestamp" is a NSString or NSNumber then

 NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue];
like image 26
Martin Babacaev Avatar answered Nov 08 '22 07:11

Martin Babacaev