iOS开发-Object-C获取手机设备信息(UIDevice)

一、获取UiDevice设备信息

// 获取设备名称
NSString *name = [[UIDevice currentDevice] name];
// 获取设备系统名称
NSString *systemName = [[UIDevice currentDevice] systemName];
// 获取系统版本
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
// 获取设备模型
NSString *model = [[UIDevice currentDevice] model];
// 获取设备本地模型
NSString *localizedModel = [[UIDevice currentDevice] localizedModel];

二、获取Bundle的相关信息

NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
// app名称
NSString *appName = infoDict[@"CFBundleName"];
// app版本
NSString *appVersion = infoDict[@"CFBundleShortVersionString"];
// app build版本
NSString *appBuild = infoDict[@"CFBundleVersion"];

NSLocal获取本地化数据:

// 获取用户的语言偏好设置列表
NSLog(@"%@", [NSLocale preferredLanguages]);

// 获取系统所有本地化标识符数组列表
NSLog(@"%@", [NSLocale availableLocaleIdentifiers]);
// 获取所有已知合法的国家代码数组列表
NSLog(@"%@", [NSLocale ISOCountryCodes]);
// 获取所有已知合法的ISO货币代码数组列表
NSLog(@"%@", [NSLocale ISOCurrencyCodes]);
// 获取所有已知合法的ISO语言代码数组列表
NSLog(@"%@", [NSLocale ISOLanguageCodes]);

// 获取当前系统设置语言的标识符
// 方法一
NSLog(@"%@", [[NSLocale currentLocale] localeIdentifier]);
// 方法二
NSLog(@"%@", [[NSLocale currentLocale] objectForKey:NSLocaleIdentifier]);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
常用的手机硬件设备信息包括: 1. 手机型号:手机的型号名称,例如iPhone X、Samsung Galaxy S10等; 2. 操作系统版本:手机所使用的操作系统版本,例如iOS 14、Android 10等; 3. CPU型号和频率:手机的处理器型号和主频,例如Qualcomm Snapdragon 855、Apple A13 Bionic等; 4. 内存大小:手机的内存容量,例如6GB、8GB等; 5. 存储容量:手机的存储空间大小,例如64GB、128GB等; 6. 屏幕分辨率:手机屏幕的分辨率,例如1920x1080、2436x1125等; 7. 相机像素:手机的摄像头像素数,例如1200万像素、4000万像素等; 8. 电池容量:手机的电池容量,例如3000mAh、4000mAh等。 获取这些信息的方法函数在不同的操作系统和编程语言中可能略有不同。在Android系统中,可以使用android.os.Build类中的各种属性获取硬件信息,例如: ``` String model = Build.MODEL; // 手机型号 String osVersion = Build.VERSION.RELEASE; // 操作系统版本 String cpuModel = Build.HARDWARE; // CPU型号 long totalMemory = Runtime.getRuntime().totalMemory(); // 内存总大小 long freeMemory = Runtime.getRuntime().freeMemory(); // 内存可用大小 File path = Environment.getDataDirectory(); // 存储路径 long totalSpace = path.getTotalSpace(); // 存储总大小 long freeSpace = path.getFreeSpace(); // 存储可用大小 DisplayMetrics dm = getResources().getDisplayMetrics(); // 获取屏幕分辨率 int screenWidth = dm.widthPixels; int screenHeight = dm.heightPixels; ``` 在iOS系统中,可以使用UIDevice类和NSProcessInfo类中的各种属性获取硬件信息,例如: ``` NSString *model = [[UIDevice currentDevice] model]; // 手机型号 NSString *osVersion = [[UIDevice currentDevice] systemVersion]; // 操作系统版本 NSString *cpuModel = [[NSProcessInfo processInfo] processorDescription]; // CPU型号 NSUInteger totalMemory = [NSProcessInfo processInfo].physicalMemory; // 内存总大小 NSUInteger freeMemory = [NSProcessInfo processInfo].availablePhysicalMemory; // 内存可用大小 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:0]; // 存储路径 NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error:nil]; NSNumber *totalSpace = [fileAttributes objectForKey:NSFileSystemSize]; // 存储总大小 NSNumber *freeSpace = [fileAttributes objectForKey:NSFileSystemFreeSize]; // 存储可用大小 CGSize screenSize = [UIScreen mainScreen].bounds.size; // 获取屏幕分辨率 CGFloat screenWidth = screenSize.width; CGFloat screenHeight = screenSize.height; ``` 需要注意的是,某些硬件信息可能需要特殊的权限才能获取,例如相机像素、电池容量等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值