iOS獲取設備型號和App版本號等信息

  1.  // 獲取當前App的基本信息字典 
  2.  NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
  3.  //app名稱  
  4.  NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
  5.  // app版本  
  6.  NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
  7.  // app build版本  
  8.  NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];  
  9.  //手機序列號  
  10.  NSString* identifierNumber = [[UIDevice currentDevice] uniqueIdentifier];  
  11.  //手機別名: 用戶定義的名稱  
  12.  NSString* userPhoneName = [[UIDevice currentDevice] name];  
  13.  //設備名稱  
  14.  NSString* deviceName = [[UIDevice currentDevice] systemName];  
  15.  //手機系統版本  
  16.  NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];   
  17.  //手機型號  
  18.  NSString* phoneModel = [[UIDevice currentDevice] model];  
  19.  //地方型號  (國際化區域名稱)  
  20.  NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];  

 

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

 

∞∞∞∞∞∞∞如何獲取內網 IP?¢¢¢¢¢¢¢¢¢¢¢¢¢ide

+ (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>ui

 

 

原文1:http://blog.csdn.net/u013935547/article/details/51782810
原文2連接:http://www.jianshu.com/p/0d84e6852c5a  spa

相關文章
相關標籤/搜索