我正在处理一个iPhone应用程序,该应用程序在完成与按钮调用相关的例程后崩溃。我正在弹出导航控制器堆栈上位置索引1处的视图。我点击按钮的当前视图位于索引5上。
我用于弹出视图的代码如下:
id callListController = [[self.navigationController viewControllers] objectAtIndex:1];
if(nil != callListController)
{
[self.navigationController popToViewController:callListController animated:YES];
}
我已尝试在上面的代码中设置断点,并且还在要在索引1处加载的视图的代码中设置断点。没有任何作用。发生了一些事情。
我使用了iphone(符号化)的崩溃报告来分析问题。老实说,我无法理解符号化文件。以下是该文件主要部分的转储,因为我无法附上此调查问卷:
Incident Identifier: BDE0FFE7-D74F-46B5-A9BD-89AA4F483300
CrashReporter Key: fbe272c09f9d46b3e962f897e0d8a5e3de9793e1
Hardware Model: iPhone1,2
Process: iwf [151]
Path: /var/mobile/Applications/F50D0AED-94A4-48A8-8B5D-0D88B2D4D36F/iwf.app/iwf
Identifier: iwf
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-02-22 20:43:10.614 -0700
OS Version: iPhone OS 4.0.1 (8A306)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x00088c24 __kill + 8
1 libSystem.B.dylib 0x00088c12 kill + 4
2 libSystem.B.dylib 0x00088c06 raise + 10
3 libSystem.B.dylib 0x0009f902 abort + 54
4 libSystem.B.dylib 0x0008e6de szone_error + 230
5 libSystem.B.dylib 0x0008e7ac free_tiny_botch + 60
6 libSystem.B.dylib 0x00001fe8 szone_free + 302
7 libSystem.B.dylib 0x00001ea0 malloc_zone_free + 64
8 CoreFoundation 0x00053cc8 __CFAllocatorSystemDeallocate + 8
9 CoreFoundation 0x000019d6 CFAllocatorDeallocate + 74
10 CoreFoundation 0x000036c4 _CFRelease + 288
11 CoreFoundation 0x00003566 CFRelease + 74
12 CoreFoundation 0x00015898 _CFAutoreleasePoolPop + 124
13 Foundation 0x00004822 -[NSAutoreleasePool release] + 98
14 UIKit 0x0007bc18 _UIApplicationHandleEvent + 7776
15 GraphicsServices 0x00004edc PurpleEventCallback + 1024
16 CoreFoundation 0x000742ac __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22
17 CoreFoundation 0x000761d6 __CFRunLoopDoSource1 + 158
18 CoreFoundation 0x0007718e __CFRunLoopRun + 574
19 CoreFoundation 0x0001e0bc CFRunLoopRunSpecific + 220
20 CoreFoundation 0x0001dfca CFRunLoopRunInMode + 54
21 GraphicsServices 0x00003f88 GSEventRunModal + 188
22 UIKit 0x00007b40 -[UIApplication _run] + 564
23 UIKit 0x00005fb8 UIApplicationMain + 964
24 iwf 0x0000d434 main (main.m:14)
25 iwf 0x0000d404 start + 32
Thread 1:
0 libSystem.B.dylib 0x00034e84 kevent + 24
1 libSystem.B.dylib 0x00102a48 _dispatch_mgr_invoke + 88
2 libSystem.B.dylib 0x00102494 _dispatch_queue_invoke + 96
3 libSystem.B.dylib 0x00102634 _dispatch_worker_thread2 + 120
4 libSystem.B.dylib 0x0008b53c _pthread_wqthread + 392
5 libSystem.B.dylib 0x00082b6c start_wqthread + 0
Thread 2:
0 libSystem.B.dylib 0x00000ab0 mach_msg_trap + 20
1 libSystem.B.dylib 0x00002f94 mach_msg + 60
2 CoreFoundation 0x00074b18 __CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x000770e0 __CFRunLoopRun + 400
4 CoreFoundation 0x0001e0bc CFRunLoopRunSpecific + 220
5 CoreFoundation 0x0001dfca CFRunLoopRunInMode + 54
6 WebCore 0x0000370c RunWebThread(void*) + 552
7 libSystem.B.dylib 0x0008af80 _pthread_start + 364
8 libSystem.B.dylib 0x0007d014 thread_start + 0
Thread 3:
0 libSystem.B.dylib 0x00000ab0 mach_msg_trap + 20
1 libSystem.B.dylib 0x00002f94 mach_msg + 60
2 CoreFoundation 0x00074b18 __CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x000770e0 __CFRunLoopRun + 400
4 CoreFoundation 0x0001e0bc CFRunLoopRunSpecific + 220
5 CoreFoundation 0x0001dfca CFRunLoopRunInMode + 54
6 Foundation 0x0003c316 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 210
7 Foundation 0x0000c612 -[NSThread main] + 42
8 Foundation 0x00092140 __NSThread__main__ + 908
9 libSystem.B.dylib 0x0008af80 _pthread_start + 364
10 libSystem.B.dylib 0x0007d014 thread_start + 0
Thread 4:
0 libSystem.B.dylib 0x00029f24 select$DARWIN_EXTSN + 20
1 CoreFoundation 0x0007aa54 __CFSocketManager + 340
2 libSystem.B.dylib 0x0008af80 _pthread_start + 364
3 libSystem.B.dylib 0x0007d014 thread_start + 0
Thread 5:
0 libSystem.B.dylib 0x0008c3b4 __workq_kernreturn + 8
1 libSystem.B.dylib 0x0008b718 _pthread_wqthread + 868
2 libSystem.B.dylib 0x00082b6c start_wqthread + 0
Thread 6:
0 libSystem.B.dylib 0x0008c3b4 __workq_kernreturn + 8
1 libSystem.B.dylib 0x0008b718 _pthread_wqthread + 868
2 libSystem.B.dylib 0x00082b6c start_wqthread + 0
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x3e73926c
r4: 0x00000006 r5: 0x067a9e50 r6: 0x0013f000 r7: 0x2fffe464
r8: 0x05559084 r9: 0x00000888 r10: 0x00000001 r11: 0x0013f000
ip: 0x00000025 sp: 0x2fffe464 lr: 0x3483fc19 pc: 0x3483fc24
cpsr: 0x000f0010
我基本了解当我转换视图时会发生此错误,但此时我几乎没有丢失。
任何建议都会有所帮助。
提前致谢。
Subbu
答案 0 :(得分:2)
正如Izzy所说,这通常是由释放自动释放对象引起的,这是一个非常常见的问题,直到你掌握了Objective-C中的内存管理。
如果您不确定具体在哪里查找问题,您可能需要先在视图中的viewWillDisappear / dealloc中注释掉所有版本,并假设它在没有崩溃的情况下工作,开始重新放入版本直到你缩小导致问题的ivar。最有可能的是,您会发现ivar被赋予一个自动释放对象的对象,因此您将不会释放该对象,保留该对象,或者使用一种方法来返回一个保留的对象。
检查此链接以获取更多背景信息:
答案 1 :(得分:0)
它崩溃了,因为你在一个视图控制器中过度释放。
P.S。在请求索引为1的对象之前,应检查viewControllers
长度。如果viewControllers
数组包含少于2个对象,则可能导致崩溃。