Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 839
user1068810 Avatar asked Nov 28 '11 06:11

user1068810


People also ask

How can you tell if it is an iPhone 4 or 4S?

Know the model number. The iPhone 4 has the following model numbers: A1332 for GSM models and A1349 for CDMA models. The iPhone 4s has these model numbers: A1431 for GSM model China, and A1387 for CDMA models and GSM models. You can see these model numbers at the back of the iPhone.

Are iPhone 4 and iPhone 4S the same size?

Both phones are 4.5 inches tall, 2.3 inches wide, and 0.37 inches thick. The only size difference between them is that, technically, the iPhone 4 weighs in at 4.8 ounces, while the 4s comes in at a whopping 4.9 ounces. Not a huge difference.

What is so special about iPhone 4S?

The iPhone 4S now has an 8 megapixel sensor and improved optics which the company claims delivers point-and-shoot quality photos. The phone is also capable of handling 1080p video. The front-facing camera remains unchanged from the iPhone 4, however, clocking in at a measly VGA resolution.

What iOS version is the iPhone 4S?

The iPhone 4S was first shipped with iOS 5, which was released on October 12, 2011, two days before the release of the device. The 4S uses iOS 5.1.1, which was released on May 7, 2012. As of April 2021, the device can be updated to iOS 9.


2 Answers

This is much simpler one. SIMPLE ENOUGH FOR JUST COPY & PASTE

Also, I've included matching model name for machine name.

//MARK: Required import #import <sys/utsname.h>  + (NSString*)deviceModelName {      struct utsname systemInfo;     uname(&systemInfo);      NSString *machineName = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];      //MARK: More official list is at     //http://theiphonewiki.com/wiki/Models     //MARK: You may just return machineName. Following is for convenience      NSDictionary *commonNamesDictionary =     @{       @"i386":     @"iPhone Simulator",    @"x86_64":   @"iPad Simulator",     @"iPhone1,1":    @"iPhone",    @"iPhone1,2":    @"iPhone 3G",    @"iPhone2,1":    @"iPhone 3GS",    @"iPhone3,1":    @"iPhone 4",    @"iPhone3,2":    @"iPhone 4(Rev A)",    @"iPhone3,3":    @"iPhone 4(CDMA)",    @"iPhone4,1":    @"iPhone 4S",    @"iPhone5,1":    @"iPhone 5(GSM)",    @"iPhone5,2":    @"iPhone 5(GSM+CDMA)",    @"iPhone5,3":    @"iPhone 5c(GSM)",    @"iPhone5,4":    @"iPhone 5c(GSM+CDMA)",    @"iPhone6,1":    @"iPhone 5s(GSM)",    @"iPhone6,2":    @"iPhone 5s(GSM+CDMA)",     @"iPhone7,1":    @"iPhone 6+ (GSM+CDMA)",    @"iPhone7,2":    @"iPhone 6 (GSM+CDMA)",     @"iPhone8,1":    @"iPhone 6S (GSM+CDMA)",    @"iPhone8,2":    @"iPhone 6S+ (GSM+CDMA)",     @"iPad1,1":  @"iPad",    @"iPad2,1":  @"iPad 2(WiFi)",    @"iPad2,2":  @"iPad 2(GSM)",    @"iPad2,3":  @"iPad 2(CDMA)",    @"iPad2,4":  @"iPad 2(WiFi Rev A)",    @"iPad2,5":  @"iPad Mini 1G (WiFi)",    @"iPad2,6":  @"iPad Mini 1G (GSM)",    @"iPad2,7":  @"iPad Mini 1G (GSM+CDMA)",    @"iPad3,1":  @"iPad 3(WiFi)",    @"iPad3,2":  @"iPad 3(GSM+CDMA)",    @"iPad3,3":  @"iPad 3(GSM)",    @"iPad3,4":  @"iPad 4(WiFi)",    @"iPad3,5":  @"iPad 4(GSM)",    @"iPad3,6":  @"iPad 4(GSM+CDMA)",     @"iPad4,1":  @"iPad Air(WiFi)",    @"iPad4,2":  @"iPad Air(GSM)",    @"iPad4,3":  @"iPad Air(GSM+CDMA)",     @"iPad5,3":  @"iPad Air 2 (WiFi)",    @"iPad5,4":  @"iPad Air 2 (GSM+CDMA)",     @"iPad4,4":  @"iPad Mini 2G (WiFi)",    @"iPad4,5":  @"iPad Mini 2G (GSM)",    @"iPad4,6":  @"iPad Mini 2G (GSM+CDMA)",     @"iPad4,7":  @"iPad Mini 3G (WiFi)",    @"iPad4,8":  @"iPad Mini 3G (GSM)",    @"iPad4,9":  @"iPad Mini 3G (GSM+CDMA)",     @"iPod1,1":  @"iPod 1st Gen",    @"iPod2,1":  @"iPod 2nd Gen",    @"iPod3,1":  @"iPod 3rd Gen",    @"iPod4,1":  @"iPod 4th Gen",    @"iPod5,1":  @"iPod 5th Gen",    @"iPod7,1":  @"iPod 6th Gen",     };      NSString *deviceName = commonNamesDictionary[machineName];      if (deviceName == nil) {         deviceName = machineName;     }      return deviceName; } 
like image 81
petershine Avatar answered Sep 20 '22 18:09

petershine


Here is a common method of retriving the device model. There are no NS methods for this, so you gotta use c

#include <sys/types.h> #include <sys/sysctl.h>  - (NSString *)machine {     NSString *machine;     size_t size;     sysctlbyname("hw.machine", NULL, &size, NULL, 0);     char *name = malloc(size);     sysctlbyname("hw.machine", name, &size, NULL, 0);     machine = [NSString stringWithUTF8String:name];     free(name);     return machine; } 
like image 42
chown Avatar answered Sep 20 '22 18:09

chown