iOS獲取設備信息常用方法
NSLog(@"HostName: %@", [[NSProcessInfo processInfo] hostName]);
//globallyUniqueString 唯一的標示符,每次調用都會不一樣,可以用作一些臨時緩存文件的名字
NSLog(@"GlobalUniqueString: %@", [[NSProcessInfo processInfo] globallyUniqueString]);
//操作系統名稱
NSLog(@"OperatingSystemName: %@", [[NSProcessInfo processInfo] operatingSystemName]);
//操作系統版本
NSLog(@"OperatingSystemVersion: %@", [[NSProcessInfo processInfo] operatingSystemVersionString]);
//物理內存
NSLog(@"PhysicalMem: %llu", [[NSProcessInfo processInfo] physicalMemory]);
//進程名稱
NSLog(@"ProcessName: %@", [[NSProcessInfo processInfo] processName]);
//供應商標識
NSLog(@"UniqueId: %@", [UIDevice currentDevice].identifierForVendor);
//設備類型(iPhone、iPad)
NSLog(@"userInterfaceIdiom: %d", [UIDevice currentDevice].userInterfaceIdiom);
//設備名字
NSLog(@"Name: %@", [UIDevice currentDevice].name);
//系統名字
NSLog(@"SystemName: %@", [UIDevice currentDevice].systemName);
//系統版本
NSLog(@"SystemVersion: %@", [UIDevice currentDevice].systemVersion);
//模型
NSLog(@"Model: %@", [UIDevice currentDevice].model);
//本地化的模型
NSLog(@"LocalizeModel: %@", [UIDevice currentDevice].localizedModel);
//電池狀態
NSLog(@"BatteryLevel: %f", [UIDevice currentDevice].batteryLevel);
//判斷設備是否是9.0以上系統 [[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0f 注意: //假如我們的設備版本號為9.1.1(為字符串類型),對其進行floatValue浮點化后值為9.100000。3. //判斷設備是否是iPhone、iPad iPad:[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
iPhone: [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhoneUIUserInterfaceIdiom in UIDevice.h typedef NS_ENUM(NSInteger, UIUserInterfaceIdiom) { #if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED UIUserInterfaceIdiomPhone, // iPhone and iPod touch style UI UIUserInterfaceIdiomPad, // iPad style UI #endif }; </pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!