Rahul Vyas
Rahul Vyas

Reputation: 28720

how to run my iphone 2.0 app in iphone os 2.0 and also 3.0 and above os

i have iphone with os ver. 2.0 i read that for app store all appplication must be run 3.0 os.so how could i make my application to run in both firmware.is there a way i can detect if os ver.>3.0 then run different statments alse run statments for lower than 3.0 os.currently i am using this.

#if __IPHONE_3_0
cell.textLabel.text=cellValue;
[cell.textLabel setFont:[UIFont systemFontOfSize:15.0]];
[cell.textLabel setLineBreakMode:UILineBreakModeTailTruncation];
#else
cell.text=cellValue;    
[cell setFont:[UIFont systemFontOfSize:15.0]];
[cell setLineBreakMode:UILineBreakModeTailTruncation];  
#endif

will it run on both firmware

i want to make my app to be run on >=3.0 os and lower than this...please help me

how do i check my application for deprecated methods...i can only see this line as deprecated cell.text=cellValue;

is there anything to change.i have installed new sdk named iphone_sdk_3.0__leopard__9m2736__final.dmg

Upvotes: 1

Views: 749

Answers (4)

garyhgaryh
garyhgaryh

Reputation: 1

The if-else directives will hide one part of the code from the compiler so it won't run on both software.

Upvotes: 0

mahboudz
mahboudz

Reputation: 39376

Your code above will not run on both sets of OSes. When you use #if statements, you are basically excluding code for one version of the OS for that particular build. In other words, each version that you build, one when you define __IPHONE_3_0 and one when you don't, will exclude the code for the other.

What you are doing is building two executables, one that is built for __IPHONE_3_0 and another for ! __IPHONE_3_0.

If you want to build one executable, that is one app, that runs on both, then you need to replace the #if statements with runtime ifs, not compile time #ifs, like:

if (theOS >= kiPhone3)
   ....
else
   ....

You can also link in libraries that are 3.0 only, but test for the availability of the framework at runtime, and then skip the call if the methods aren't available. There are different calls you'll need to use, one for checking to see if a method is available, and one for if a class is available:

Class newClass = (NSClassFromString(@"NewClassName"));
    if (newClass != nil)

Last thing, there is a later version of the SDK than the one you mentioned.

Good luck!

Upvotes: 1

Benno
Benno

Reputation: 5640

If you build it against the 2.0 (or 2.1, or 2.2.1, etc) SDK, it will run on that SDK and any later version unless Apple specifically discontinue support for that SDK. I see plenty of apps in the App Store that say they work with iPhone OS 2.x or later and they run fine on my iPhone 3G running 3.1.

Upvotes: 0

Vladimir
Vladimir

Reputation: 170809

There was a similar post some time ago. Have a look at Apple's MailComposer sample to see en example of an app that supports both 3.0 and 2.x firmware

Upvotes: 1

Related Questions