ios 各种设备cpu架构分类:
arm64e : iPhone 12 | iPhone 12 Mini | iPhone 12 Pro | iPhone 12 Pro Max
arm64e : iPhone 11 | iPhone 11 Pro | iPhone 11 Pro Max
arm64e : iphone XS | iphone XS Max | iphoneXR
arm64 : iPhone 8 | iPhone 8 Plus | and iPhone X
arm64 : iPhone 7 | iPhone 7 Plus | iPad (2018)
arm64 : iPhone 6S | iPhone 6S Plus
arm64 : iPhone 6 | iPhone 6 Plus
arm64 : iPhone 5S
armv7s :iPhone5 | iPhone5C | iPad4(iPad with Retina Display)
armv7 :iPhone4 | iPhone4S | iPad | iPad2 | iPad3(The New iPad) | iPad mini | iPod Touch 3G | iPod Touch4
各种类型占的字节数:
32位系统 int 占4个字节,long占 4个字节, long long 占 8个字节, NSInteger 占 4个字节
64位系统 int 占4个字节,long 占 8个字节, long Long占 8个字节.NSInteger 占 8个字节
NSInteger的定义?
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
为什么要搞个NSInteger?
我猜是为了cpu进行操作计算,提高计算效率
开发中用到的各种输出符号?
NSInteger n1 = 3;
//整型,ld是long 的输出占位符,因为现在基本都是64位,所以也可以用ld和lu来作为NSinteger的占位符.
NSLog(@"n1:%zd",n1);
NSLog(@"n1: %ld",n1);
//而无符号的分别变为tu lu
NSUInteger n2 = 5;
NSLog(@"n2:%tu",n2);
NSLog(@"n2:%lu",n2);
//int类型
int n3 = 4;
NSLog(@"n3:%d",n3);
unsigned int n4 = 5;
NSLog(@"%u", n4);
//long类型
long n5 = 10;
NSLog(@"n5: %ld",n5);
unsigned long n6 = 12;
NSLog(@"n6: %lu",n6);
//longlong 类型
long long n7 = 15;
NSLog(@"n7:%lld",n7);
unsigned long long n8 = 20;
NSLog(@"n8:%llu",n8);
// 十六进制输出
NSInteger n9 = 23;
NSLog(@"n9: %lx",n9);
//总位数为3, 不足前面加0
NSInteger n10 = 40;
NSLog(@"n10:%03ld",n10);
//输出总位数为8,不足前面不补0
NSInteger n11 = 50;
NSLog(@"n11:%8ld",n11);
//限制输出的小数位数为 3位
float n12 = 9.1389;
NSLog(@"%.2f",n12);
//总位数和小数一块要求
float n13 = 17.55886;
//整数和小数一共 5位,3位小数.
NSLog(@"%5.3f",n13);