【发布时间】:2015-03-20 10:24:19
【问题描述】:
演员不是正确的词,但请耐心等待。我有以下字符串:
NSString *string = @"01700000";
但是,我需要检查它是否包含我正在寻找的特定位:
if (bitshift & (1 << 21)) {
NSLog(@"YES");
} else {
NSLog(@"NO");
}
使用[string integerValue] 获取整数值会产生意想不到的结果:
NSInteger bitshift = (1 << 24) | (1 << 22) | (1 << 21) | (1 << 20);
NSString *flags = @"01700000";
NSInteger bitshiftString = [flags integerValue];
// bitshift: 1700000, bitshiftString: 19f0a0
NSLog(@"bitshift: %tx, bitshiftString: %tx", bitshift, bitshiftString);
将此字符串值扫描成NSInteger 的最合适方法是什么?
【问题讨论】:
标签: objective-c nsstring nsinteger