Is it possible to detect that your iOS app is running on an iPad mini at runtime?

Boxel's answer would be good if it didn't invoke undefined behavior and if it didn't have superfluous parts. One, + [NSString stringWithCString:encoding:] requires a C string - that is, a NUL-terminated char pointer (else it will most likely dump core). Also, you don't need the conversion to NSString - since sysctlbyname() provides you with a plain old C string (without the NUL terminator, of course), you can directly use strcmp() to save a few dozen CPU cycles:

#include <sys/sysctl.h>

size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size + 1);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
machine[size] = 0;

if (strcmp(machine, "iPad2,5") == 0) {
    /* iPad mini */
}

free(machine);

Edit: now that answer is fixed as well.


Use sysctlbyname to get the platform string, then compare it with the IPSW prefix strings listed here. It looks like the only currently known iPad Mini is "iPad2,5"

Example:

size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size + 1);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
machine[size] = 0;

if(strcmp(machine, "iPad2,5") == 0) {
    // do something special on the iPad Mini    
}

free(machine);

There is no reliable, future-proof way to detect the iPad mini's pixel density. Other answers suggest looking at the hw.machine string. But we don't know (as of the time I write this) what the strings will be for the iPad mini cellular models (though we can make an educated guess: iPad2,6 will probably have GSM and iPad2,7 will probably have CDMA).

It's fine to look at the hw.machine string for analytics. But it's dangerous to let it affect your app's user interface, because even the iPad2,5 string for the current iPad mini is subject to change.

When the iPad 2 came out, the wifi model's string was iPad2,1. Later (when they released the iPad 3), they changed the iPad 2 hardware and changed the hw.machine string to iPad2,4, but they still called it the iPad 2. The same thing could happen with the iPad mini - or even with the iPad 2 again! For example, Apple could release yet another version of the iPad 2 hardware and give it the machine string iPad2,8.