开发者

How do I distinguish iPad 1 from iPad 2 in Cocoa?

My app needs to know where iPad's mic is, and the only way I know is to see if 开发者_如何学编程it's running on iPad, or on iPad 2, and act accordingly.

So - how do I check the device model?


To do exactly this, you need:

if(![[UIDevice currentDevice].model isEqualToString:@"iPad2"])
{
UIAlertView *alertView = [UIAlertView alloc] initWithTitle:@"Error" 
message:@"Microphone not present" 
delegate:self 
cancelButtonTitle:@"Dismiss" 
otherButtonTitles: nil];
[alertView show];
[alertView release];
}

Taken from here

But as I said above, it'd be better to test for the presence of a Microphone than for the exact model. What if someone is using an iPad 1 with an external microphone?

EDIT: This is the correct method, apologies, Merlin.

Also covered in this stackoverflow question.

Dave


This SO answer provides a detailed method for using the sysctlbyname("hw.machine"... system.

Determine device (iPhone, iPod Touch) with iPhone SDK

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜