haisergeant
haisergeant

Reputation: 1111

iphone: run application from iOS 4.2 on iOS 3.2

I have a problem. I develop a application, this app run successfully on iOS 4.2. Now I would like to run it on iOS 3.2, but the application crash before it load. Because of this line of code:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod) name:UIApplicationWillEnterForegroundNotification object:nil];

I understand that UIApplicationWillEnterForegroundNotification is not available for iOS 3.2. But when I use:

#ifdef __IPHONE_4_0
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDataAfterEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
#endif

The application still run in that line of code and cause crash again. I don't know what should I do to let 3.2 does not run that line of code.

Thank you very much

Upvotes: 0

Views: 336

Answers (2)

Ishu
Ishu

Reputation: 12787

use this

// #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000

  NSLog( @"After Version 4.0" ); 
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDataAfterEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];

// #else

// #endif

Upvotes: 1

Jamie
Jamie

Reputation: 5122

Check out this post. Probably better to do it like this or something similar.

How to detect current iOS is 4.1 or 4.2?

Upvotes: 1

Related Questions