I have an NSString that represents a time in mm:ss
format. How do i convert it in int64_t
so i can submit it as a score in game center?
If you wanted to be rigorous you could use an NSDateFormatter to convert to an NSDate then get an NSTimeInterval from that; if you wanted to be more direct then you might try something as simple as:
NSArray *components = [string componentsSeparatedByString:@":"];
if([components count] != 2)
{
// some error condition
return;
}
int64_t totalSeconds = ([[components objectAtIndex:0] integerValue] * 60) +
[[components objectAtIndex:1] integerValue];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.