views:

1993

answers:

3

HI all

I want to make one app for iPhone 2.2.* and for version 3.0. Some method in 2.2* is deprecated in 3.0. ( like UITableViewCell setText and setLabel )

Is there any way to check which firmware version is used on iPhone and to set different method to use

+11  A: 

You will need to use pre-processor directives for the conditional compilation such as __IPHONE_3_0 and build two separate executables.

For example:

 #ifdef __IPHONE_3_0
 // code specific to version 3
 #else
 // code specific to version 2
 #end

If you need to detect the version at run-time you can use [[UIDevice currentDevice] systemVersion]. It returns the string with the current version of the iPhone OS.

roustem
Practically speaking, building two separate executables for different versions of iPhone OS is not a good user experience. It contributes to confusion and compatibility problems. Instead, if your app is compatible with with prior versions of iPhone OS, check for the availability of newer APIs at runtime.
Elliot
+4  A: 

As I mentioned in the comments before, check: http://stackoverflow.com/questions/820142/how-to-target-a-specific-iphone-version

Kriem
A: 

As mentioned in the other referenced thread, while you can use pre-processor directives to generate two applications from one code base, you will still need two applications (one for 2.x and one for 3.x)

A compile time directive cannot be used to make a run time decision.

There's more detail in the other thread.

mmc