Ⅰ iOS如何判断是iOS11系统的宏定义
系统宏汇集__FILE__ 当前文件所在目录 __DATE__ “替代文字”是一个含有编译日期的字符串字面值,日期格式为“mm dd yyyy”(例如:“Mar 19 2006”)。如果日期小于10日,就在日的前面放一个空格符。NSLog(@"_DATE_=%s",__DATE__);__FUNCTION__ 当前函数名称__LINE__ 当前语句在源文件中的行数__TIME__此字符串字面值包含编译时间,格式为“hh:mm:ss”(范例:“08:00:59”)。__STDC__整数常量1,表示此编译器遵循ISOC标准。__STDC_VERSION__ 如何实现复合C89整部1,则这个宏的值为19940SL;如果实现符合C99,则这个宏的值为199901L;否则数值是未定义__STDC_EOBTED__(C99)实现为宿主实现时为1,实现为独立实现为0__STDC_IEC_559__ (C99)浮点数实现复合IBC 60559标准时定义为1,否者数值是未定义__STDC_IEC_559_COMPLEX__ (C99)复数运算实现复合IBC 60559标准时定义为1,否者数值是未定义__STDC_ISO_10646__ (C99)定义为长整型常量,yyyymmL表示wchar_t值复合ISO 10646标准及其指定年月的修订补充,否则数值未定义
Ⅱ 如何用宏区分ios工程和macos工程
像种需要用宏实现定义同工程共同代码部用宏判断
Ⅲ 宏定义怎样得到ios的系统版本
获得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设备
开发当中几种判断当前iOS设备的实现方法,简单粗暴的代码段展现,希望对大家能有所帮助。1.在程序中涉及到全屏的宽高的时候,初始化的时候,代码中不要写320和480#define Screen_height [[UIScreen mainScreen] bounds].size.height #define Screen_width [[UIScreen mainScreen] bounds].size.width 2.使用宏定义方法判断#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) if(iPhone5){ /*代码操作*/ }else{ /*代码操作*/ } if([ [ UIDevice currentDevice ] userInterfaceIdiom ] == UIUserInterfaceIdiomPhone ){ //IPhone设备 }else{ //ipad设备 }网上还有一种方法:+ (NSString*)deviceString { // 需要#import "sys/utsname.h" struct utsname systemInfo; uname(&systemInfo); NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; if ([deviceString isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; if ([deviceString isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; if ([deviceString isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS"; if ([deviceString isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; if ([deviceString isEqualToString:@"iPhone4,1"]) return @"iPhone 4S"; if ([deviceString isEqualToString:@"iPhone5,2"]) return @"iPhone 5"; if ([deviceString isEqualToString:@"iPhone3,2"]) return @"Verizon iPhone 4"; if ([deviceString isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G"; if ([deviceString isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G"; if ([deviceString isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G"; if ([deviceString isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G"; if ([deviceString isEqualToString:@"iPad1,1"]) return @"iPad"; if ([deviceString isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)"; if ([deviceString isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)"; if ([deviceString isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)"; if ([deviceString isEqualToString:@"i386"]) return @"Simulator"; if ([deviceString isEqualToString:@"x86_64"]) return @"Simulator"; NSLog(@"NOTE: Unknown device type: %@", deviceString); return deviceString; }转载