How do I create an NSDate from a Unix timestamp?
channel.startDate = [NSDate dateWithTimeIntervalSince1970: (NSTimeInterval)[channelJson objectForKey:@"broadcastStartedTime"]];
I get this error:
104: error: pointer value used where a floating point value was expected
channels.startDate
is an NSDate*
. The value for the key "broadcastStartedTime" is a Javascript Number
converted into an NSNumber
or NSDecimalNumber
by the SBJson parser library.
Try this instead:
NSNumber *startTime = channelJson[@"broadcastStartedTime"]; channel.startDate = [NSDate dateWithTimeIntervalSince1970:[startTime doubleValue]];
Your value is trapped in a pointer type of NSNumber
. The dateWithTimeIntervalSince1970
method is expecting a primitive NSTimeInterval
(which, under the covers, is a double
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With