我有一个字符串" 999999999999528106"我将它传递给NSScanner,但输出不正确。结果得到2147483647。
我猜我的字符串的大小不适合NSInteger。任何线索
NSScanner *aScanner = [NSScanner scannerWithString:iString];
NSMutableCharacterSet *aCharset = [NSMutableCharacterSet whitespaceAndNewlineCharacterSet];
[aCharset formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
[aScanner setCharactersToBeSkipped:[aCharset copy]];
NSInteger anIntegerResult = 0;
[aScanner setScanLocation:0];
if ([aScanner scanInteger:&anIntegerResult] && aScanner.isAtEnd)
return @(anIntegerResult);
答案 0 :(得分:2)