Tim
Tim

Reputation: 13258

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.

Upvotes: 6

Views: 5123

Answers (3)

taskinoor
taskinoor

Reputation: 46037

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

NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue];

Upvotes: 16

Martin Babacaev
Martin Babacaev

Reputation: 6280

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

 NSTimeInterval myTimestamp = [[myJSON objectForKey:@"thetimestamp"] doubleValue];

Upvotes: 1

Oleg Danu
Oleg Danu

Reputation: 4159

Try

NSTimeInterval *myTimestamp = (NSTimeInterval*)[myJSON objectForKey:@"thetimestamp"];

Upvotes: -4

Related Questions