Flipkart Search

Search This Blog

Wednesday, September 23, 2009

Run your iPhone application on both iPhone OS 2.0 and iPhone OS 3.0 and above versions

first of all in your application delegate create a varaible like this

your appdelegate header file.

float version;

then create property for accessing to another classes

@property (nonatomic, assign) float version;

in appdelegate implementation file

@synthesize version;

in this method
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    version =[[[UIDevice currentDevice] systemVersion] floatValue];
    //NSLog(@"Current version no=%f",version);

now in the class where you are getting warning of method deprecations...
in header file of class
declare this

@class yourAppDelegate;

now where you declare instance variable declare your appdelegate.
    yourAppDelegate *AppDelegate;

now in implementation file of the class
import header file of your appdelegate
#import "yourAppDelegate.h"

in the viewDidLoadMethod.

- (void)viewDidLoad {
    [super viewDidLoad];
    AppDelegate=[[UIApplication sharedApplication] delegate];

 now where you are getting warning use this code.I am using temporary statements you can put your code.

if (AppDelegate.version >= 3.0)

       //put your 3.0 code here
        NSLog(@"Current OS VErsion %f",AppDelegate.version);
        [cell.textLabel setFont:[UIFont systemFontOfSize:15.0]];
        [cell.textLabel setLineBreakMode:UILineBreakModeTailTruncation];// iPhone 3.0 code here

        //put your 2.0 code here
        NSLog(@"Current OS VErsion %f",AppDelegate.version);
        [cell setFont:[UIFont systemFontOfSize:15.0]];
        [cell setLineBreakMode:UILineBreakModeTailTruncation];

use this everywhere to get rid of those warnings..

now the final part.

set active target device 3.0 debug.

change base sdk to 3.0

and change deployment target to iphone os 2.0.

note you will get warnings but don't worry it will work fine.

to check it's working run your app in any iphone which have 2.0 OS.

if you don't have iPhone with OS 3.0 check in simulator.

1 comment:

iPhone Application Development said...

thanks for your technical post... found very useful...