0

我有一个由 fetchedResultsController 驱动的简单表视图控制器,当我选择它时它经常崩溃,崩溃日志是这样的;

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xc21eb7ad
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x3c0ce5d0 objc_msgSend + 16
1   UIKit                           0x3623c564 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 404
2   UIKit                           0x3622138c -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1312
3   UIKit                           0x36238822 -[UITableView layoutSubviews] + 202
4   UIKit                           0x361f48c2 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254
5   QuartzCore                      0x35fa050e -[CALayer layoutSublayers] + 210
6   QuartzCore                      0x35fa00b0 CA::Layer::layout_if_needed(CA::Transaction*) + 456
7   QuartzCore                      0x35fa0fd4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
8   QuartzCore                      0x35fa09be CA::Context::commit_transaction(CA::Transaction*) + 234
9   QuartzCore                      0x35fa07d0 CA::Transaction::commit() + 312
10  QuartzCore                      0x35fa0634 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
11  CoreFoundation                  0x343b793e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
12  CoreFoundation                  0x343b5c34 __CFRunLoopDoObservers + 272
13  CoreFoundation                  0x343b5f8e __CFRunLoopRun + 742
14  CoreFoundation                  0x34329238 CFRunLoopRunSpecific + 352
15  CoreFoundation                  0x343290c4 CFRunLoopRunInMode + 100
16  GraphicsServices                0x37f07336 GSEventRunModal + 70
17  UIKit                           0x362452b4 UIApplicationMain + 1116
18  Introdex                        0x0011e538 0xa3000 + 505144
19  Introdex                        0x000a5a24 0xa3000 + 10788

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x3c5b75d0 kevent64 + 24
1   libdispatch.dylib               0x3c4f2d22 _dispatch_mgr_invoke + 806
2   libdispatch.dylib               0x3c4ee374 _dispatch_mgr_thread + 32

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x3c5b6e30 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3c5b6fd0 mach_msg + 48
2   CoreFoundation                  0x343b72b6 __CFRunLoopServiceMachPort + 126
3   CoreFoundation                  0x343b602c __CFRunLoopRun + 900
4   CoreFoundation                  0x34329238 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x343290c4 CFRunLoopRunInMode + 100
6   WebCore                         0x3a328390 RunWebThread(void*) + 440
7   libsystem_c.dylib               0x3c5200de _pthread_start + 306
8   libsystem_c.dylib               0x3c51ffa4 thread_start + 4

Thread 3:
0   libsystem_kernel.dylib          0x3c5b6e30 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3c5b6fd0 mach_msg + 48
2   CoreFoundation                  0x343b72b6 __CFRunLoopServiceMachPort + 126
3   CoreFoundation                  0x343b602c __CFRunLoopRun + 900
4   CoreFoundation                  0x34329238 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x343290c4 CFRunLoopRunInMode + 100
6   Foundation                      0x34c4d5be -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7   Foundation                      0x34cf0c40 -[NSRunLoop(NSRunLoop) run] + 76
8   Introdex                        0x0021924c 0xa3000 + 1532492
9   Foundation                      0x34cfa22c __NSThread__main__ + 968
10  libsystem_c.dylib               0x3c5200de _pthread_start + 306
11  libsystem_c.dylib               0x3c51ffa4 thread_start + 4

Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x3c5b6e30 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3c5b6fd0 mach_msg + 48
2   CoreFoundation                  0x343b72b6 __CFRunLoopServiceMachPort + 126
3   CoreFoundation                  0x343b602c __CFRunLoopRun + 900
4   CoreFoundation                  0x34329238 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x343290c4 CFRunLoopRunInMode + 100
6   Foundation                      0x34c76888 +[NSURLConnection(Loader) _resourceLoadLoop:] + 304
7   Foundation                      0x34cfa22c __NSThread__main__ + 968
8   libsystem_c.dylib               0x3c5200de _pthread_start + 306
9   libsystem_c.dylib               0x3c51ffa4 thread_start + 4

Thread 5 name:  com.apple.CFSocket.private
Thread 5:
0   libsystem_kernel.dylib          0x3c5c7594 __select + 20
1   CoreFoundation                  0x343bb474 __CFSocketManager + 676
2   libsystem_c.dylib               0x3c5200de _pthread_start + 306
3   libsystem_c.dylib               0x3c51ffa4 thread_start + 4

Thread 6 name:  JavaScriptCore::BlockFree
Thread 6:
0   libsystem_kernel.dylib          0x3c5c708c __psynch_cvwait + 24
1   libsystem_c.dylib               0x3c518afc _pthread_cond_wait + 644
2   libsystem_c.dylib               0x3c518870 pthread_cond_timedwait + 40
3   JavaScriptCore                  0x382fddf6 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 102
4   JavaScriptCore                  0x38410532 JSC::BlockAllocator::blockFreeingThreadMain() + 78
5   JavaScriptCore                  0x38423030 WTF::wtfThreadEntryPoint(void*) + 12
6   libsystem_c.dylib               0x3c5200de _pthread_start + 306
7   libsystem_c.dylib               0x3c51ffa4 thread_start + 4

Thread 7 name:  JavaScriptCore::Marking
Thread 7:
0   libsystem_kernel.dylib          0x3c5c708c __psynch_cvwait + 24
1   libsystem_c.dylib               0x3c518afc _pthread_cond_wait + 644
2   libsystem_c.dylib               0x3c522cf8 pthread_cond_wait + 36
3   JavaScriptCore                  0x383a36dc JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 140
4   JavaScriptCore                  0x383a3620 JSC::MarkStackThreadSharedData::markingThreadMain() + 140
5   JavaScriptCore                  0x38423030 WTF::wtfThreadEntryPoint(void*) + 12
6   libsystem_c.dylib               0x3c5200de _pthread_start + 306
7   libsystem_c.dylib     

有人可以解释一下这个崩溃日志的含义。我无法正确阅读它,也不知道这实际上意味着什么。如果有人可以帮助我,那就太好了。

4

1 回答 1

0

不看你的代码,很难知道你哪里出错了。

但据我所知,如果您能够成功显示 Table 上的数据并在单击特定行时崩溃。以下是一些可能性。

1)。确保您已在控制器的头文件中声明 UITableViewDelegate。

解决方案:确保你有这个(在 .h 文件中)

@interface FavViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>

2)。忘记将委托与文件所有者联系起来

解决方案:打开 Layout 的 XIB 文件 --> 选择 UITableView --> 在 Connection Inspector --> 将委托拖到文件的所有者(如下图所示)

在此处输入图像描述

您可以通过在 .m 文件的 viewDidLoad 方法中以编程方式执行此操作来实现相同的目的

favourite_tbl.delegate=self;//favourite_tbl is instance of myTableView

3)。你的didSelectRowAtIndexPath方法(点击行)应该像

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    selectedIndex = indexPath.row;

    NSLog(@"you have selected %d",selectedIndex);

}

如果您对此有任何问题,请随时给我留言。

于 2013-03-07T06:36:34.003 回答