How to programmatically differentiate between iphone 4 and iphone 4S?

后端 未结 7 1600
醉酒成梦
醉酒成梦 2020-11-29 18:08

I am working on app which needs to check the iphone model, but I\'m not able to find any solution. I will be thank full for any suggestion.

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 18:48

    For my purposes I've written a tiny library that abstracts away the underlying C calls and presents an Objective-C interface.

    NSLog(@"Big model number: %d", deviceDetails.bigModel);
    //Big model number: 4
    
    NSLog(@"Small model number: %d", deviceDetails.smallModel);
    //Small model number: 1
    
    if (deviceDetails.model == GBDeviceModeliPhone4S) {
        NSLog(@"It's a 4S");
    }
    //It's a 4S
    
    if (deviceDetails.family != GBDeviceFamilyiPad) {
        NSLog(@"It's not an iPad");
    }
    //It's not an iPad
    
    NSLog(@"systemInfo string: %@", [GBDeviceInfo rawSystemInfoString]);
    //systemInfo string: iPhone4,1
    

    It's on github: GBDeviceInfo

提交回复
热议问题