0
float serverTime = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] floatValue];

NSLog(@"String: %@ Float: %f", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding], serverTime);

responseData 是 NSMutableData。通过 NSURLConnection 接收数据。这是返回:

2013-04-29 11:02:44.479 Time Test[7894:907] String: 1367247763.97 Float: 1367247744.000000
2013-04-29 11:02:44.996 Time Test[7894:907] String: 1367247764.41 Float: 1367247744.000000
2013-04-29 11:02:45.524 Time Test[7894:907] String: 1367247764.94 Float: 1367247744.000000

这里发生了什么?

4

1 回答 1

0

你必须使用双精度而不是整数。

于 2013-04-29T15:21:48.877 回答