Ios 在32位iPhone上处理64位整数
我想在iPhone4S(当然有32位ARM6处理器)上处理64位无符号整数 当尝试使用64位无符号整数(例如Twitter ID)时,我遇到以下问题:Ios 在32位iPhone上处理64位整数,ios,objective-c,arm,nsuinteger,Ios,Objective C,Arm,Nsuinteger,我想在iPhone4S(当然有32位ARM6处理器)上处理64位无符号整数 当尝试使用64位无符号整数(例如Twitter ID)时,我遇到以下问题: // Array holding the 64 bit integer IDs of the Tweets in a timeline: NSArray *Ids =[timelineData valueForKeyPath:@"id"]; // I would like to get the minimum of these IDs: NSU
// Array holding the 64 bit integer IDs of the Tweets in a timeline:
NSArray *Ids =[timelineData valueForKeyPath:@"id"];
// I would like to get the minimum of these IDs:
NSUInteger minId = (NSUInteger) Ids.lastObject;
数组Ids
包含以下数字(=Tweet id):
但是,minId
返回不正确的值399999248
(而不是491621445655867393
)
如何在iPhone 4s上找到64位整数数组中的最小或最后一个对象?您需要使用始终为64位的类型,而不是
NSUInteger
。您可以使用uint64\u t
或unsigned long
。您还需要从NSNumber中获取整数值(数组不能存储C类型)。要做到这一点,你需要打电话
uint64_t minID = [Ids.lastObject longLongValue];
编辑
更改为在示例代码中使用uint64_t,正如正确指出的那样,这更好地显示了您的意图。我将使用
uint64_t
表示您特别需要64位数据类型。
uint64_t minID = [Ids.lastObject longLongValue];