獲得IOS系統版本號
[[[UIDevice currentDevice] systemVersion] floatValue]
獲得硬體名稱
+ (NSString*)getMachine{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);
NSString *machine = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
free(name);
if( [machine isEqualToString:@"i386"] || [machine isEqualToString:@"x86_64"] ) machine = @"ios_Simulator";
else if( [machine isEqualToString:@"iPhone1,1"] ) machine = @"iPhone_1G";
else if( [machine isEqualToString:@"iPhone1,2"] ) machine = @"iPhone_3G";
else if( [machine isEqualToString:@"iPhone2,1"] ) machine = @"iPhone_3GS";
else if( [machine isEqualToString:@"iPhone3,1"] ) machine = @"iPhone_4";
else if( [machine isEqualToString:@"iPod1,1"] ) machine = @"iPod_Touch_1G";
else if( [machine isEqualToString:@"iPod2,1"] ) machine = @"iPod_Touch_2G";
else if( [machine isEqualToString:@"iPod3,1"] ) machine = @"iPod_Touch_3G";
else if( [machine isEqualToString:@"iPod4,1"] ) machine = @"iPod_Touch_4G";
else if( [machine isEqualToString:@"iPad1,1"] ) machine = @"iPad_1";
else if( [machine isEqualToString:@"iPad2,1"] ) machine = @"iPad_2";
return machine;
}
㈡ ios swift怎麼使用oc的宏
如果沒c語言基礎就直接搞swift吧,swift把oc中一些比較麻煩的東西進行了改進。比如字元串的賦值,oc中分引用賦值和顯式,初學者很可能會亂用導致bug,swift里統一了,所有字元串賦值都是一個出來。
還有各種mutable和immutable的類,oc中採用在類名前面加個Mutable來區分,當初第一次用NSArray的時候硬是找不到Add方法,原來在NSMutableArray里。
Swift里用let和var兩個關鍵字就把它們區分出來了,更自然,還少打字。然後Swift還支持范型,不需要像oc那樣,從集合里挑個NSObject出來再強制轉換。
㈢ IOS或者安卓系統的手機,什麼軟體可以運行EXCEL宏
2017年老版的可以的,就是找不到