[iOS]iOS獲取設備信息常常用法

郝萌主傾心貢獻。尊重做者的勞動成果。請勿轉載。緩存

假設文章對您有所幫助。歡迎給做者捐贈。支持郝萌主。捐贈數額任意,重在心意^_^ 
ide

我要捐贈: 點擊捐贈post

Cocos2d-X源代碼下載:點我傳送spa

遊戲官方下載:http://dwz.cn/RwTjl操作系統

遊戲視頻預覽:http://dwz.cn/RzHHd.net

遊戲開發博客:http://dwz.cn/RzJzIcode

遊戲源代碼傳送http://dwz.cn/Nret1orm


1. 常常用法視頻

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);

2. 推斷設備是不是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] == UIUserInterfaceIdiomPhone

UIUserInterfaceIdiom 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
};

郝萌主傾心貢獻,尊重做者的勞動成果,請勿轉載。blog

假設文章對您有所幫助,歡迎給做者捐贈,支持郝萌主,捐贈數額任意。重在心意^_^ 

我要捐贈: 點擊捐贈

Cocos2d-X源代碼下載:點我傳送

遊戲官方下載:http://dwz.cn/RwTjl

遊戲視頻預覽:http://dwz.cn/RzHHd

遊戲開發博客:http://dwz.cn/RzJzI

遊戲源代碼傳送http://dwz.cn/Nret1

相關文章
相關標籤/搜索