iPhone - App crashes on start up on iOS 3.x (_UIApplicationDidEnterBackgroundNotification)

StackOverflow https://stackoverflow.com/questions/11212143

  •  17-06-2021
  •  | 
  •  

I have Three20 in my app which supports iOS 3.0 and above.

When I run the app with iOS 3.0, iOS 3.1, the app crashes right away when launching.

Below is my crash report:

Date/Time:       2012-06-26 10:38:36.761 -0600
OS Version:      iPhone OS 3.1.3 (7E18)
Report Version:  104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000001, 0xe7ffdefe
Crashed Thread:  0

Dyld Error Message:
  Symbol not found: _UIApplicationDidEnterBackgroundNotification
  Referenced from: /var/mobile/Applications/8E9E6F79-80BB-4CCD-A510-CCBF7BB78BE8/MyApp.app/MyApp
  Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
  Dyld Version: 149

Do you know what is going on,
Am I missing something in the build settings?

UPDATE 1:
So I do a search for UIApplicationDidEnterBackgroundNotification
in my project, and there are 3 results found in TTBaseNavigator.m file.

one in this segment

#ifdef __IPHONE_4_0
UIKIT_EXTERN NSString *const UIApplicationDidEnterBackgroundNotification
__attribute__((weak_import));
UIKIT_EXTERN NSString *const UIApplicationWillEnterForegroundNotification
__attribute__((weak_import));
#endif

and two in this method

- (id)init {
    self = [super init];
  if (self) {
    _URLMap = [[TTURLMap alloc] init];
    _persistenceMode = TTNavigatorPersistenceModeNone;

    NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
    [center addObserver:self
               selector:@selector(applicationWillLeaveForeground:)
                   name:UIApplicationWillTerminateNotification
                 object:nil];
#ifdef __IPHONE_4_0
    if (nil != &UIApplicationDidEnterBackgroundNotification) {
      [center addObserver:self
                 selector:@selector(applicationWillLeaveForeground:)
                     name:UIApplicationDidEnterBackgroundNotification
                   object:nil];
    }
#endif
  }
  return self;
}

Do you know how to tweak these code so that the app will runs on iOS 3.0 and iOS 3.1.

UPDATE 2:

Currently I don't use TTBaseNavigator so I comment the two #ifdef __IPHONE_4_0 blocks.
This fixes my problem, but I wonder if anyone has other solution to make this work by not commenting Three20 code.

Many thanks.

有帮助吗?

解决方案 2

I comment the two #ifdef __IPHONE_4_0 blocks. (please see update 1)
This fixes my problem.

其他提示

In the documentation for the UIApplicationDidEnterBackgroundNotification event it says, "Available in iOS 4.0 and later."

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top