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
这里发生了什么?
答案 0 :(得分:0)
你必须使用double而不是整数。