Am unable to identify the device models (iphone , ipad ,ipod touch, iphpne simulator) while programming (in 3.2 version). Alreay am tried with UIDevice Class and some other means, but am unable to get model as ipad when connected to ipad. every time it is giving model other than ipad. So can any one please help me out. Thank you.
0
votes
3 Answers
1
votes
I've used this code and it works really well:
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine];
free(machine);
return platform;
This come from arstechnica.com.
0
votes
The general approach is to avoid trying to guess device models by yourself. In most of the cases (but you didn't described your original need), the framework provides you the HW capabilities from the API and you don't really have to know which models you're using in reality.
For instance, if you want to know if a camera is available, you're not going to check in your code if (model==iphone3G || model==iPhone3Gs)
You're just going to ask something like [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]
that is part of the public API.
[UIDevice model]
? – notnoop