iOS设备信息的获取

来源:互联网 发布:sql 格式化字符串 编辑:程序博客网 时间:2024/05/21 09:44

方法1:
+ (NSString*)getDeviceVer{    size_t size;    sysctlbyname("hw.machine", NULL, &size, NULL, 0);    char *machine = (char*)malloc(size);    sysctlbyname("hw.machine", machine, &size, NULL, 0);    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];    free(machine);    return platform;}

方法2:
struct utsname systemInfo;uname(&systemInfo);NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
方法3:只能获取iPhone还是iPad 无法获取型号

[[UIDevice currentDevice]model]

获取设备操作系统信息

获取手机信息的方法:UIDevice  NSBundle 

UIDevice: [UIDevice currentDevice] 

Name  设备名称

identifierForVendor  UUID

systemName  系统名称

systemVersion系统版本号

model  设备模式(iphone  ipod touch)

localizeModel  本地设备模式

NSBundle:

[[NSBundle mainBundle] infoDictionary]

可以获取plist中的信息:应用ID 名称 应用版本 渠道 系统版本 等

获取系统分辨率

+(NSString*)getScreen{    CGRect rect_screen = [[UIScreen mainScreen] bounds];    CGFloat rect_scale = [UIScreen mainScreen].scale;    CGFloat width = rect_scale*rect_screen.size.width;    CGFloat height = rect_scale*rect_screen.size.height;    return [NSString stringWithFormat:@"%.0fx%.0f",width,height];}
获取网络类型





0 0