NSTimeInterval & # 8594; incompatible pointer types

I have NSTimeInterval and I have a JSON value of 1257808000000 .

I'm doing it:

  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 wishes.

+6
objective-c iphone
source share
3 answers

NSTimeInterval is actually a double value. This is not an object.

 NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue]; 
+16
source share

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

  NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue]; 
+1
source share

Try

 NSTimeInterval *myTimestamp = (NSTimeInterval*)[myJSON objectForKey:@"thetimestamp"]; 
-4
source share

All Articles