我正在将项目的 NSString 转换为 int,以便比较时间戳。这是我转换它时从我的 NSLog 得到的响应。
Server Time Stamp = 1363032033711 AND Server Time Stamp CONVERTED: 2147483647
我正在使用此代码进行转换:
NSString *msg = [NSString stringWithFormat:@"%@", message];
NSArray *subString = [msg componentsSeparatedByString:@" "];
NSString *timeStamp = [subString lastObject];
int serverTimeStamp = [timeStamp intValue];
NSLog(@"Server Time Stamp = %@ AND Server Time Stamp CONVERTED: %d", timeStamp, serverTimeStamp);
我不确定为什么转换后的数字如此奇怪,是我的代码有问题,还是将字符串转换为整数?