PDA

View Full Version : Two versions of an app- one iPhone and one iPod touch




I'm a Mac
Feb 24, 2009, 03:25 PM
Does anyone know if it's possible to make two versions of the same app (same title) - one for the iPhone and one for the iPod touch? If so, how would you do this? would you submit two different apps? Would both apps show up in the app store under the same title and the device would automatically choose?

Thanks.



Jeremy1026
Feb 24, 2009, 03:45 PM
Does anyone know if it's possible to make two versions of the same app (same title) - one for the iPhone and one for the iPod touch? If so, how would you do this? would you submit two different apps? Would both apps show up in the app store under the same title and the device would automatically choose?

Thanks.

Why not just build your app to interact with touches differently then phones?

I'm a Mac
Feb 24, 2009, 04:00 PM
I'm not quite sure what you mean, but there's only a small difference that I need for for the two devices on my app. I have an image view, and for an iPhone, I want it to load a certain image, and for an iPod touch, I want it to load a different image. Is there anyway I would be able to do that without having the user go into some sort of preferences?

nottooshabby
Feb 24, 2009, 04:47 PM
I'm not quite sure what you mean, but there's only a small difference that I need for for the two devices on my app. I have an image view, and for an iPhone, I want it to load a certain image, and for an iPod touch, I want it to load a different image. Is there anyway I would be able to do that without having the user go into some sort of preferences?

I'm pretty certain you can query the device to find out what it is, then use some simple if and else logic.

dejo
Feb 24, 2009, 05:12 PM
I'm pretty certain you can query the device to find out what it is, then use some simple if and else logic.
Agreed. You certainly can. The model property of UIDevice contains either @”iPhone” or @”iPod touch”.

I'm a Mac
Feb 24, 2009, 05:18 PM
So how would I fit that into an ApplicationDidFinishLaunching method? I'm sorry I'm sort of new at programming

dejo
Feb 24, 2009, 06:09 PM
So how would I fit that into an ApplicationDidFinishLaunching method? I'm sorry I'm sort of new at programming
If you're not sure how to put together a simple if-then-else test that is based on the property of a built-in class, I would suggest that you need to spend a bunch more time learning the basics of Objective-C coding before you go much further. Being new to programming is not a bad thing. It just means you have some learning to do before you can be competent enough to start coding that next-great iPhone app. You could start by looking at the stickies and guides at the top of this iPhone Programming forum.

Jeremy1026
Feb 24, 2009, 07:02 PM
If you're not sure how to put together a simple if-then-else test that is based on the property of a built-in class, I would suggest that you need to spend a bunch more time learning the basics of Objective-C coding before you go much further. Being new to programming is not a bad thing. It just means you have some learning to do before you can be competent enough to start coding that next-great iPhone app. You could start by looking at the stickies and guides at the top of this iPhone Programming forum.

I think his problem is getting the device, no the if statement.

UIDevice *myCurrentDevice = [UIDevice currentDevice];
NSString *theDevice = [NSString stringWithFormat=@"%@",[myCurrentDevice model]];

That will return either iPod Touch, iPhone, or Simulator depending on which device it is on.

Then you will simply compare the strings against @"iPhone" or whatever and perform the proper image loading for the device.

I'm a Mac
Feb 24, 2009, 07:03 PM
Double post. Sorry.

I'm a Mac
Feb 24, 2009, 07:05 PM
I think his problem is getting the device, no the if statement.


Thank you. It was partly my fault, I phrased the question poorly, but I'm glad you understood me. I would consider myself fairly competent in understanding Objective-c, I'm just not completely familiar with all of the Cocoa and Cocoa touch methods

I'm a Mac
Feb 24, 2009, 10:57 PM
Thanks you so much for all of your help. Now, it appears I'm having an Objective-C issue. For some reason, even though I can get the model name, my iPhone won't respond to the if loop for it's correct model name (it just goes to else)

- (void)applicationDidFinishLaunching:(UIApplication *)application {

UIDevice *myCurrentDevice = [UIDevice currentDevice];
NSString *theDevice = [NSString stringWithFormat:@"%@",[myCurrentDevice model]];
NSLog(@"The current model is %@", theDevice);
//The Debugger logs that the model is indeed an iPhone

if (theDevice == @"iPhone") {
NSLog(@"Using the iPhone");
//That is not getting logged

dejo
Feb 25, 2009, 12:04 AM
Try
if ([theDevice isEqual:@"iPhone"])
instead.

The == is simply comparing pointer values, which will always be different for your code since you're allocating theDevice's own memory space through the stringWithFormat call.

I'm a Mac
Feb 25, 2009, 03:52 PM
Thanks, it worked.