SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
11/25/13 05:23 AM (11 years ago)

Testing for iPad, Xcode 5, BT iOS v3

For some odd reason, the following which used to work in Xcode 4/Btv2 doesn't work in 5/3: if([appDelegate.rootDevice isIPad]){ // do stuff } However, I did find that this works perfectly, and is a paste over replacement: if([[[UIDevice currentDevice] model] isEqual: @"iPad"]){ // do stuff… } Hope this saves you some time… if([UIScreen mainScreen].bounds.size.height == 568) { // iPhone 5 } else { // iPhone 4 } still works as expected. Cheers! -- Smug Edit: If you're going full boat, and want to test whether it's a device on iOS 6 or 7, this is working good for me: if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1){ // iOS 5 and 6 stuff... if([[[UIDevice currentDevice] model] isEqual: @"iPad"]){ [BT_debugger showIt:self theMessage:@"iPad. iOS 5-6"]; // for iPad iOS 6 and below... }else { if([UIScreen mainScreen].bounds.size.height == 568) { [BT_debugger showIt:self theMessage:@"iPhone5 with iOS 6? phooey"]; // for iPhone 5 with iOS 6 and below… It will never happen }else{ [BT_debugger showIt:self theMessage:@"iPhone 3/4 iOS 5 or 6"]; } } } else { // iOS 7 stuff... if([[[UIDevice currentDevice] model] isEqual: @"iPad"]){ [BT_debugger showIt:self theMessage:@"iPad with iOS 7"]; }else { if([UIScreen mainScreen].bounds.size.height == 568) { [BT_debugger showIt:self theMessage:@"iPhone5 with iOS 7"]; }else{ [BT_debugger showIt:self theMessage:@"iPhone 4 with iOS 7"]; } } } Sorry the pretty formatting gets lost in the editor…
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
11/25/13 01:33 PM (11 years ago)
Thanks Smug!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.