私は次の通知に登録しています:私はしかし、単純にこれを登録することで、私はEXC_BAD_ACCESSS
時にアプリを取得、これは前のiOSのバージョンのようにすべての状況で呼び出されていないことを知っているIOS4でUIApplicationWillTerminateNotificationを処理する方法は? iOS4をで
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appWillTerminate:)
name:UIApplicationWillTerminateNotification
object:[UIApplication sharedApplication]];
-(void)appWillTerminate:(UIApplication *) app {
NSLog(@"terminate");
}
を終了します。それでも、私のアプリがiOS3.0 +をサポートしているため、削除できません。これをどうすれば処理できますか?
UPDATE:ここではクラッシュログです:。。あなたは何ができるか
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000011
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000441c objc_msgSend + 20
1 Foundation 0x00015432 _nsnote_callback + 150
2 CoreFoundation 0x000271da __CFXNotificationPost_old + 390
3 CoreFoundation 0x00026e7a _CFXNotificationPostNotification + 122
4 Foundation 0x00004720 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
5 Foundation 0x0000de3a -[NSNotificationCenter postNotificationName:object:] + 14
6 UIKit 0x000bef10 -[UIApplication _terminateWithStatus:] + 164
7 UIKit 0x000be1b0 -[UIApplication _handleApplicationSuspend:eventInfo:] + 1980
8 UIKit 0x0007e4a0 -[UIApplication handleEvent:withNewEvent:] + 3620
9 UIKit 0x0007d470 -[UIApplication sendEvent:] + 60
10 UIKit 0x0007ccf8 _UIApplicationHandleEvent + 6804
11 GraphicsServices 0x00005dd8 PurpleEventCallback + 1024
12 CoreFoundation 0x00035e40 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22
13 CoreFoundation 0x00035dfe __CFRunLoopDoSource1 + 158
14 CoreFoundation 0x0002809e __CFRunLoopRun + 574
15 CoreFoundation 0x00027d74 CFRunLoopRunSpecific + 220
16 CoreFoundation 0x00027c82 CFRunLoopRunInMode + 54
17 GraphicsServices 0x00004e84 GSEventRunModal + 188
18 UIKit 0x00004f8c -[UIApplication _run] + 564
19 UIKit 0x000024cc UIApplicationMain + 964
EXC_BAD_ACCESSはおそらく無関係です。私は 'UIApplicationWillTerminateNotification'がmustitaskingをサポートするデバイスでは送信されないとは思わない。 'applicationWillEnterBackground:'またはそれに対応する通知にコードがありますか? –
奇妙なことに、 'applicationWillEnterBackground'ですべてのコードを削除しても、同じことが起こります。その上で、' UIApplicationWillTerminateNotification'の通知を取り除いても問題ありません。また、これはシミュレータ上ではなくデバイス上でのみ発生します。質問をクラッシュログに更新します。 –