g.revolution
g.revolution

Reputation: 12262

iPhone development: what will [[UIDevice currentDevice] model] return for "iPad"?

What will [[UIDevice currentDevice] model] return for "iPad"?

Upvotes: 2

Views: 12654

Answers (4)

timv
timv

Reputation: 3366

I tried using containsString but it was not allowed with xcode4

Here is how I solved it:

if ([[[UIDevice currentDevice] model] hasPrefix:@"iPhone"])
    {

Hope this helps even if its a bit late.

Upvotes: 3

jrtc27
jrtc27

Reputation: 8536

You can use UI_USER_INTERFACE_IDIOM(), which will either return UIUserInterfaceIdiomPhone or UIUserInterfaceIdiomPad. Bear in mind that on any device < 3.2, this is unavailable, so first check to see whether the property can be retrieved - in this case, it is not an iPad.

Or, alternatively, to specifically work out whether the platform is an iPad or not, use

if ([[[UIDevice currentDevice] model] containsString:@"iPad"]) {
    // Your code goes here
}

Hope this helps ;)

Upvotes: 2

Madhup Singh Yadav
Madhup Singh Yadav

Reputation: 8124

Well trying on simulator:

NSLog(@"%@",[[UIDevice currentDevice] model]);

it gives iPad Simulator, will update the answer when I will get the device ;)

Upvotes: 1

Alex Reynolds
Alex Reynolds

Reputation: 96974

You might try the Apple Developer Forums.

Upvotes: 0

Related Questions