我的应用程序在进入前台时会崩溃两次。我努力模拟,但我不能。我也附上了崩溃日志。我无法从这个日志中得到理由。帮助我解决这个问题。提前致谢。
Incident Identifier: 644DF722-CCB1-4A62-9802-43AAE8FD7998
CrashReporter Key: a78f95d5bb2b0cb796602919073666aa96af75e4
Hardware Model: iPhone5,1
Process: myapp [1611]
Path: /var/mobile/Applications/5123A551-8D9B-4890-89B9-10AF4A84FDDF/myapp.app/myapp
Identifier: com.myapp.iphone.myappequ
Version: 6.0 (6.0)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-12-19 16:36:10.710 -0600
OS Version: iOS 7.0.4 (11B554a)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x2e65fe7e __exceptionPreprocess + 126
1 libobjc.A.dylib 0x389bc6c2 objc_exception_throw + 34
2 CoreFoundation 0x2e595ff4 -[__NSArrayI objectAtIndex:] + 172
3 myapp 0x0010a4f2 0xee000 + 115954
4 UIKit 0x30de8956 -[UIViewController loadViewIfRequired] + 514
5 UIKit 0x30de8714 -[UIViewController view] + 20
6 UIKit 0x30e60588 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 384
7 UIKit 0x30e5eeec -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1196
8 UIKit 0x30e5ea32 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 42
9 UIKit 0x30e5e9ba -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 90
10 UIKit 0x30e5e952 -[UIWindow _setRotatableViewOrientation:duration:force:] + 38
11 UIKit 0x30e57454 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 104
12 UIKit 0x30dea392 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 378
13 UIKit 0x30e5e6a4 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 692
14 UIKit 0x30e5e178 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 156
15 UIKit 0x30def57c -[UIWindow addRootViewControllerViewIfPossible] + 460
16 UIKit 0x30decae0 -[UIWindow _setHidden:forced:] + 304
17 UIKit 0x30e57828 -[UIWindow makeKeyAndVisible] + 56
18 myapp 0xee000 + 22384
19 UIKit 0x30e54aa8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
20 UIKit 0x30e544ee -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1386
21 UIKit 0x30e4eb3c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 716
22 UIKit 0x30de9a02 -[UIApplication handleEvent:withNewEvent:] + 3138
23 UIKit 0x30de8cf8 -[UIApplication sendEvent:] + 68
24 myapp 0x00153774 0xee000 + 415604
25 UIKit 0x30e4e31c _UIApplicationHandleEvent + 660
26 GraphicsServices 0x332ce768 _PurpleEventCallback + 604
27 GraphicsServices 0x332ce352 PurpleEventCallback + 30
28 CoreFoundation 0x2e62a772 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
29 CoreFoundation 0x2e62a70e __CFRunLoopDoSource1 + 342
30 CoreFoundation 0x2e628eda __CFRunLoopRun + 1402
31 CoreFoundation 0x2e59346c CFRunLoopRunSpecific + 520
32 CoreFoundation 0x2e59324e CFRunLoopRunInMode + 102
33 UIKit 0x30e4d5be -[UIApplication _run] + 758
34 UIKit 0x30e48840 UIApplicationMain + 1132
35 myapp 0x000f3136 0xee000 + 20790
36 myapp 0xee000 + 20668
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x38f6c1fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x38fd3a4e pthread_kill + 54
2 libsystem_c.dylib 0x38f1d028 abort + 72
3 libc++abi.dylib 0x3836b98a abort_message + 70
4 libc++abi.dylib 0x383846e2 default_terminate_handler() + 250
5 libobjc.A.dylib 0x389bc936 _objc_terminate() + 190
6 libc++abi.dylib 0x383821b0 std::__terminate(void (*)()) + 76
7 libc++abi.dylib 0x38381d12 __cxa_rethrow + 98
8 libobjc.A.dylib 0x389bc80a objc_exception_rethrow + 38
9 CoreFoundation 0x2e5934e2 CFRunLoopRunSpecific + 638
10 CoreFoundation 0x2e59324e CFRunLoopRunInMode + 102
11 UIKit 0x30e4d5be -[UIApplication _run] + 758
12 UIKit 0x30e48840 UIApplicationMain + 1132
13 myapp 0x000f3136 0xee000 + 20790
14 myapp 0x000f30bc 0xee000 + 20668
Thread 1:
0 libsystem_kernel.dylib 0x38f59838 kevent64 + 24
1 libdispatch.dylib 0x38ea80d0 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x38ea261e _dispatch_mgr_thread + 34
Thread 2:
0 libsystem_kernel.dylib 0x38f6cc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38fd0e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38fd0cc0 start_wqthread + 4
Thread 3:
0 libsystem_kernel.dylib 0x38f6cc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38fd0e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38fd0cc0 start_wqthread + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x00000000 r2: 0x00000000 r3: 0x00002060
r4: 0x00000006 r5: 0x3ad9918c r6: 0x00000000 r7: 0x27d15594
r8: 0x14d8cfd0 r9: 0x00000001 r10: 0x14e50ea0 r11: 0x14e8c7a0
ip: 0x00000148 sp: 0x27d15588 lr: 0x38fd3a53 pc: 0x38f6c1fc
cpsr: 0x00000010
applicationWillEnterForeground中的代码
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
[application endBackgroundTask:self.bgTaskId];
self.bgTaskId = UIBackgroundTaskInvalid;
}
答案 0 :(得分:1)
问题不在你的AppDelegate代码中,它可能在UIViewController中加载,可能在viewDidLoad
。崩溃没有完全符号化,如第3行所示:“myapp”应该显示代码中的对象和消息。
要获得更全面的答案,请在应用启动时屏幕上显示的viewDidLoad
发布您的UIViewController
代码。
答案 1 :(得分:0)
检查loadView
和/或viewDidLoad
中的语句(因为这是iOS loadViewIfRequired
调用的)NSArray
中访问对象的内容。
还要看一下here,类似于堆栈跟踪的顶部。
答案 2 :(得分:0)
当应用程序进入前台时,您会尝试访问NSArray中的数据,这些数据在应用程序转到后台时会失效。尝试注册
//in viewWillAppear
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAppComingToForeground)name:UIApplicationWillEnterForegroundNotification object:nil];
//in viewWillDisapear
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
并且在handleAppComingToForeground方法中,您可以重新初始化Array的数据。
同样,您可以为UIApplicationDidEnterBackgroundNotification设置观察者,并在app转到后台时存储viewcontroller级别数据。