Application Platform Specification - iphone

I am designing an app for iphone & ipod the client wants the Some of the UI Specification for iphone and ipod to be different so i decided to create different XIB Files for iphone and ipod as in universal apps for iphone and ipod but the problem is that i am not able differentiate between iphone and ipod on run time is there any way to check platform on runtime so as to load different Nib Files on runtime
If there is any code or tutorial please guide me to the link
Thanks in advance

[[UIDevice currentDevice] model] looks like the right source for this Information. You can check it if it contains iPod Touch or iPhone or.....

Check the model property of UIDevice class
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html
However, if you switch on that string, be aware that the simulator shows up as a separate device.
This:
NSString* model = [[UIDevice currentDevice] model];
NSLog(#"model: %#", model);
Outputs:
2011-10-25 08:44:30.794 Craplet[921:b303] model: iPhone Simulator

I think this was already asked several times .)
NSString *dtype = [UIDevice currentDevice].model;
if([dtype isEqualToString:#"iPhone"])
{
// iphone
}
Possible examples of model strings are #”iPhone” and #”iPod touch”

Related

iOS5 CMMotionManager startDeviceMotionUpdatesToQueue: fails on iPhone3GS

I have a software-hardware related issue that I'm trying to troubleshoot. My app was developed for iPhone4, iOS5 and uses Core Motion framework to process accelerometer and gyroscope data in real time. The app fails when running on iPhone 3GS with iOS5
My main core-motion method looks like this:
[motionManager startDeviceMotionUpdatesToQueue:motionQueue withHandler:^(CMDeviceMotion *motion, NSError *error) {
//notify calibration delegate
if(calibrationDelegate)
{
[calibrationDelegate collectCalibrationMotionData:motion];
}
//a lot more processing
}
I have reports that iPhone3GS does not return yes to isGyroAvailable, while iPhone4 returns yes.
BOOL accelerometerAvailable = (motionManager.isAccelerometerAvailable)?YES:NO;
BOOL gyroscopeAvailable = (motionManager.isGyroAvailable)?YES:NO;
if(!accelerometerAvailable && ! gyroscopeAvailable)
{
//handle error
remoteControlState = kRemoteControlStateError;
}
I've painfully discovered that Apple sells my app to customers with iPhone4, 4s AND 3GS. The app does not work for customers with iPhone 3GS because the call above does not seem to pass the motion objects to the calibration delegate.
I do not have iPhone 3GS to test the app on, so I have a few questions:
Is it possible to specify anywhere in the XCode project properties
that I want my app to run ONLY on iPhone4 and above? (or devices with gyroscope available?)
Where can I find more information on iOS5 quirks like the one above
to better understand how iPhone3GS differs from iPhone4?
Is it possible to specify anywhere in the XCode project properties that I want my app to run ONLY on iPhone4 and above? (or devices with gyroscope available?)
Yes, you would specify such dependencies in the UIRequiredDeviceCapabilities key of your Info.plist (gyroscope would be the requirement in this case).
However, for a released app, it's unfortunately impossible to add new requirements.

best practice to write app both for ios4.3, ios5 and ipad

I am just started write app for ios.
I have 2 questions.
I know there are some codes which work fine in ios4.3 but don't work in ios5 and the opposite is also true.I want to know,which is the best practice for writing app both for ios4.3 and ios5?Is it acceptable run-time to check the version for specific parts of code??
I am also should write same app for ipad. So, I want to know which is the best practice for writing app for iphone which works also on ipad??
Thanks
iOS 5 or iOS 4
Another way to detect the version is to use the respondsToSelector: message on objects. The advantage compared to the version method is that you don't need to know what the next versions of iOS are gonna be to maintain your application. (What if, for instance, a new 5.0.2 version shows up? Your app should know that the "5.0.2" string is newer than "5.0"? I agree it would not be complicated to code, but using respondsToSelector: is much more convenient)
iPhone/iPod Touch or iPad
My usual way to code universal app (ie iPhone and iPad) is to define a basic implementation of my custom UIViewController classes, and then implement an HD version of it, inheriting the default behavior but customizing it for the iPad (overriding methods works well but the delegate pattern might be better: you get compilation warnings if you forget to implement methods).
If you use a different .xib file from the beginning of your application lifecycle (that's what you get by universal Xcode-provided templates), you may end up defining classes just from Interface Builder, and won't need to implement any runtime test in your code to know if you're running on an iPhone or an iPad.
You can get the version using:
[[UIDevice currentDevice] systemVersion];
The systemVersion returns a string, like "5.0". You can then compare the strings using string comparison. For example:
NSString *requiredVersion = #"5.0";
NSString *currentVersion = [[UIDevice currentDevice] systemVersion];
if ([currentVersion compare:requiredVersion options:NSNumericSearch] != NSOrderedAscending)
isItSupported = TRUE;
The documentation indicates that you can use the following to determine if you have an iPhone or iPad:
[[UIDevice currentDevice] model];
I've not used this though.
See the documentation.

create NSBundle

I want to create an application that work with iphone 3 and 4.
so I have images for iphone 3 and others for 4.
now I want my application to load resources based on ios version
the part of detecting ios version is easy.
the problem is that i want to know how to create new NSBundle and use it to make application load resources from different bundle based on detected ios version.
if your resource is only concerned with image then you are not required to put any extra effort to do that. Suppose you have a image named myHome.png for 3 then rename the same image for 4 to myHome#2x.png. It will automatically take that image if the device is iPhone4.
If the resource is any thing other than image then you need to do conditional coding i.e you need to check for a condition every time you are trying to access such resource and the code will look something like this
1 to check if its iPhone of iPad do this
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:#"iPhone"])
{
//do your work for iPhone
}
2 To check between iOS version you can try this link this the best I know

Turing off functionality dpending on device iPhone, or iPod touch

I have what i thought was a relatively simple question but i cannot find an answer to it yet. I have an iPhone app that uses GPS on one of its screens. I want to disable this screen using code when the app loads,so disable it when a iPod touch is being used. This is so it can still be useful on a iPod touch as there is a lot of functionality that a iPod touch user can use.
Thanks.
You can get there with #Aaron's answer, but that's not the way to do it. Use [CLLocationManager locationServicesEnabled]; to tell if you can determine the users's location. This is a lot more robust than making decisions based on the device model.
to get the device info..
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html
NSString *deviceType = [UIDevice currentDevice].model;
I think if you are just checking for GPS then you will need to access the CLLocationManager to see if it is on or off

How can I detect which system my App Store application is running on?

I am developing a Cocoa Touch application for Apple's App store and I want to do some tweaking in the code depending on what device it's running on. How can I tell?
I've used this in a Universal app to determine if the code is running on an iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// Do iPad only stuff here
}
Check out the documentation for UIDevice
Look at UIDevice and it's properties. There is a systemVersion string that will work for what you want.