您的位置:首页 > 移动开发

iOS获取设备型号和App版本号等信息

2016-12-20 00:00 489 查看
摘要: 222

// 获取当前App的基本信息字典

NSDictionary *infoDictionary = [[NSBundle mainBundle] 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];

//手机别名: 用户定义的名称

NSString* userPhoneName = [[UIDevice currentDevice] name];

//设备名称

NSString* deviceName = [[UIDevice currentDevice] systemName];

//手机系统版本

NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];

//手机型号

NSString* phoneModel = [[UIDevice currentDevice] model];

//地方型号 (国际化区域名称)

NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];

最新消息-http://www.jianshu.com/p/0d84e6852c5a#

∞∞∞∞∞∞∞如何获取内网 IP?¢¢¢¢¢¢¢¢¢¢¢¢¢

+ (NSString *)deviceIPAdress
{
NSString *address = @"an error occurred when obtaining ip address";
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;

success = getifaddrs(&interfaces);

if (success == 0)
{ // 0 表示获取成功

temp_addr = interfaces;
while (temp_addr != NULL)
{
if (temp_addr->ifa_addr->sa_family == AF_INET)
{
// Check if interface is en0 which is the wifi connection on the iPhone
if ([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"])
{
// Get NSString from C String
address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
}
}
temp_addr = temp_addr->ifa_next;
}
}

freeifaddrs(interfaces);

NSLog(@"手机的IP是:%@", address);
return address;
}
记得导入:
#import <arpa/inet.h>
#import <ifaddrs.h>

原文1:http://blog.csdn.net/u013935547/article/details/51782810
原文2链接:http://www.jianshu.com/p/0d84e6852c5a
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐