目录:
1、获取当前设备类型
2、获取当前语言环境
3、获取当前APP版本号
1、获取当前设备类型
//0-iPod touch/1-iPhone/2-iPad/3-iPhone Simulator/4-iPad Simulator
+(int)deviceType
{
NSString *machineType = [[UIDevice currentDevice] model];
//设备
if ([machineType compare:@"iPod touch"] == NSOrderedSame)
return 0;
else if ([machineType compare:@"iPhone"] == NSOrderedSame)
return 1;
else if ([machineType compare:@"iPad"] == NSOrderedSame)
return 2;
//模拟器
else if ([machineType compare:@"iPhone Simulator"] == NSOrderedSame)
return 3;
else if ([machineType compare:@"iPad Simulator"] == NSOrderedSame)
return 4;
//其他类型
return -1;
}
2、获取当前语言环境
+(NSString*)deviceLanguages
{
return [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0];
}
3、获取当前APP版本号
+ (NSString *)projectVerson
{
NSDictionary *infoDict =[[NSBundle mainBundle] infoDictionary];
NSString *softVerson =[infoDict objectForKey:@"CFBundleShortVersionString"];
return softVerson;
}