欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS开发中手机版本号、序列号、应用名称等相关字段获取教程

程序员文章站 2023-02-20 08:20:52
ios手机版本号、序列号、应用名称等相关字段获取 nsbundle mainbundle相关字段获取 nsdictionary *infodictionary = [[nsbundle mainbu...

ios手机版本号、序列号、应用名称等相关字段获取
nsbundle mainbundle相关字段获取

nsdictionary *infodictionary = [[nsbundle mainbundle] infodictionary];
cfshow(infodictionary);
// app名称
nsstring *app_name = [infodictionary objectforkey:@”cfbundledisplayname”];
// app版本
nsstring *app_version = [infodictionary objectforkey:@”cfbundleshortversionstring”];
// app build版本
nsstring *app_build = [infodictionary objectforkey:@”cfbundleversion”];

//手机序列号  
nsstring* identifiernumber = [[uidevice currentdevice] uniqueidentifier];  
nslog(@"手机序列号: %@",identifiernumber);  
//手机别名: 用户定义的名称  
nsstring* userphonename = [[uidevice currentdevice] name];  
nslog(@"手机别名: %@", userphonename);  
//设备名称  
nsstring* devicename = [[uidevice currentdevice] systemname];  
nslog(@"设备名称: %@",devicename );  
//手机系统版本  
nsstring* phoneversion = [[uidevice currentdevice] systemversion];  
nslog(@"手机系统版本: %@", phoneversion);  
//手机型号  
nsstring* phonemodel = [[uidevice currentdevice] model];  
nslog(@"手机型号: %@",phonemodel );  
//地方型号  (国际化区域名称)  
nsstring* localphonemodel = [[uidevice currentdevice] localizedmodel];  
nslog(@"国际化区域名称: %@",localphonemodel );  

nsdictionary *infodictionary = [[nsbundle mainbundle] infodictionary];  
// 当前应用名称  
nsstring *appcurname = [infodictionary objectforkey:@"cfbundledisplayname"];  
nslog(@"当前应用名称:%@",appcurname);  
// 当前应用软件版本  比如:1.0.1  
nsstring *appcurversion = [infodictionary objectforkey:@"cfbundleshortversionstring"];  
nslog(@"当前应用软件版本:%@",appcurversion);  
// 当前应用版本号码   int类型  
nsstring *appcurversionnum = [infodictionary objectforkey:@"cfbundleversion"];  
nslog(@"当前应用版本号码:%@",appcurversionnum);