iOS 獲取本機的裝置資訊UIDevice

joker_king發表於2018-12-20

UIDevice

//使用類方法來獲取當前的裝置
UIDevice *myDecive = [UIDevice currentDevice];
//裝置名稱
NSLog(@"name-------%@",myDecive.name);
//裝置模式
NSLog(@"model--------%@",myDecive.model);
//裝置的本地模式
NSLog(@"localizedModel---------%@",myDecive.localizedModel);
//系統的名稱
NSLog(@"systemName--------%@",myDecive.systemName);
//系統版本
NSLog(@"systemVersion---------%@",myDecive.systemVersion);
//裝置的朝向
NSLog(@"orientation---------%ld",(long)myDecive.orientation);
//裝置的uuid,使用NSUUID來將獲取的uuid轉換成字串,以便於我們後期使用
NSLog(@"identifierForVendor---%@",myDecive.identifierForVendor.UUIDString);
//當前裝置是否有轉向通知
NSLog(@"%d",myDecive.isGeneratingDeviceOrientationNotifications);
//電池的狀態
NSLog(@"batteryState-----%ld",(long)myDecive.batteryState);
//電量的百分比
NSLog(@"batteryLevel--------+%f",myDecive.batteryLevel);
複製程式碼

控制檯輸出的資訊

2016-06-03 20:29:52.646 UIDevice[40489:442865] name-------iPhone Simulator
2016-06-03 20:29:52.646 UIDevice[40489:442865] model--------iPhone
2016-06-03 20:29:52.647 UIDevice[40489:442865] localizedModel---------iPhone
2016-06-03 20:29:52.647 UIDevice[40489:442865] systemName--------iPhone OS
2016-06-03 20:29:52.648 UIDevice[40489:442865] systemVersion---------9.2
2016-06-03 20:29:52.648 UIDevice[40489:442865] orientation---------0
2016-06-03 20:29:52.649 UIDevice[40489:442865] identifierForVendor---FAB6E912-40B7-465B-8C62-A8EFDED7462B
2016-06-03 20:29:52.649 UIDevice[40489:442865] 1
2016-06-03 20:29:52.649 UIDevice[40489:442865] batteryState-----0
2016-06-03 20:29:52.649 UIDevice[40489:442865] batteryLevel--------+-1.000000
複製程式碼

相關文章