Chinaunix首页 | 论坛 | 博客
  • 博客访问: 718789
  • 博文数量: 260
  • 博客积分: 7033
  • 博客等级: 少将
  • 技术积分: 2633
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-13 23:15
文章分类

全部博文(260)

文章存档

2012年(2)

2011年(41)

2010年(78)

2009年(139)

我的朋友

分类: 嵌入式

2010-10-31 15:15:26

How to get iPhone OS number ? 收藏

To check current iPhone OS version whether satisfy requirement

  1. NSString *reqSysVer = @"3.1";  
  2. NSString *currSysVer = [[UIDevice currentDevice] systemVersion];  
  3. if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)  
  4.     bellowReqSysVer = TRUE;  
 
Another useful info
  1. NSLog([[UIDevice currentDevice] name]); // Name of the phone as named by user  
  2. NSLog([[UIDevice currentDevice] uniqueIdentifier]); // A GUID like string  
  3. NSLog([[UIDevice currentDevice] systemName]); // "iPhone OS"   
  4. NSLog([[UIDevice currentDevice] systemVersion]); // "2.2.1"  
  5. NSLog([[UIDevice currentDevice] model]); // "iPhone" on both devices  
  6. NSLog([[UIDevice currentDevice] localizedModel]); // "iPhone" on both devices  
 
How to determine iPhone 3G or iPhone 3GS ?
  1. #import   
  2. #import   
  3. - (NSString *)machine  
  4. {  
  5.     size_t size;  
  6.       
  7.     // Set 'oldp' parameter to NULL to get the size of the data  
  8.     // returned so we can allocate appropriate amount of space  
  9.     sysctlbyname("hw.machine", NULL, &size, NULL, 0);   
  10.       
  11.     // Allocate the space to store name  
  12.     char *name = malloc(size);  
  13.       
  14.     // Get the platform name  
  15.     sysctlbyname("hw.machine", name, &size, NULL, 0);  
  16.       
  17.     // Place name into a string  
  18.     NSString *machine = [NSString stringWithCString:name];  
  19.       
  20.     // Done with this  
  21.     free(name);  
  22.       
  23.     return machine;  
  24. }  
 

The return values will be as follows:

  • iPhone Simulator == i386
  • iPhone == iPhone1,1
  • 3G iPhone == iPhone1,2
  • 3GS iPhone == iPhone2,1
  • 1st Gen iPod == iPod1,1
  • 2nd Gen iPod == iPod2,1

    阅读(679) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~