How do i encode and decode NSTimeInterval?
when i do it in this way...
NSTimeInterval refreshInterval;
[coder encodeObject:refreshInterval forKey:@"refreshinterval"];
it throws an error saying , incompatible type
How to solve this problem?
or the correspoinding thing is to convert NSTimeInterval to int and vice-verse.. but i'm not finding any method for convertion..
please do suggest me how to solve this problem.
Thank You.
NSDate.h:
typedef double NSTimeInterval;
So, you may treat to NSTimeInterval as double. Conversion to int - (int)interval
or round(interval)
.
Re coder, I'm not completely sure, but it seems, that encodeObject receives (id) as a parameter. double is an atomic type, so you should wrap it with NSNumber:
[coder encodeObject:[NSNumber numberWithDouble:refreshInterval] forKey:@"refreshinterval"];