如何解决" RemoveObjectAtIndex"

时间:2016-04-27 12:51:15

标签: ios nsarray

我有一个属性:

@property(nonatomic,retain)QBChatDialog *对话框;

当我在viewWillDisappear中将其设为nil时,它会给我错误

- (void)viewWillDisappear:(BOOL)animated {

      self.dialog = nil;

}

我收到以下错误:

-[__NSArrayM removeObjectAtIndex:]: index 2147483647 beyond bounds for empty array'

即使我不使用" removeObjectAtIndex"。我认为这是在内部调用。

如何追踪这一点。

我的完整堆栈跟踪是:

   (
0   CoreFoundation                      0x05504494 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x05cd6e02 objc_exception_throw + 50
2   CoreFoundation                      0x0540b2cd -[__NSArrayM removeObjectAtIndex:] + 445
3   Qboy                                0x0026d23e -[TWMessageBarViewController statusBarHidden] + 43262
4   Qboy                                0x002acffc QBAFQueryStringPairsFromKeyAndValue + 110104
5   libobjc.A.dylib                     0x05cea060 _ZN11objc_object17sidetable_releaseEb + 238
6   libobjc.A.dylib                     0x05ce9361 objc_release + 65
7   libobjc.A.dylib                     0x05ce9318 objc_storeStrong + 39
8   Qboy                                0x0007a35a -[ChatVC .cxx_destruct] + 298
9   libobjc.A.dylib                     0x05cd58e2 _ZL27object_cxxDestructFromClassP11objc_objectP10objc_class + 116
10  libobjc.A.dylib                     0x05cd5869 object_cxxDestruct + 20
11  libobjc.A.dylib                     0x05cdfcb6 objc_destructInstance + 48
12  CoreFoundation                      0x0550e57c -[NSObject(NSObject) __dealloc_zombie] + 156
13  UIKit                               0x038de904 -[UIResponder dealloc] + 162
14  UIKit                               0x03855e85 -[UIViewController dealloc] + 2296
15  Qboy                                0x0017bf93 -[QMChatViewController dealloc] + 835
16  UIKit                               0x040c1b75 -[UIViewController(UIKitManual) release] + 88
17  libobjc.A.dylib                     0x05ce934f objc_release + 47
18  libobjc.A.dylib                     0x05cea52d _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 371
19  CoreFoundation                      0x053d48a8 _CFAutoreleasePoolPop + 24
20  CoreFoundation                      0x0540c43c __CFRunLoopRun + 2364
21  CoreFoundation                      0x0540b846 CFRunLoopRunSpecific + 470
22  CoreFoundation                      0x0540b65b CFRunLoopRunInMode + 123
23  GraphicsServices                    0x06eef664 GSEventRunModal + 192
24  GraphicsServices                    0x06eef4a1 GSEventRun + 104
25  UIKit                               0x03688eb9 UIApplicationMain + 160
26  Qboy                                0x000db84a main + 138
27  libdyld.dylib                       0x062cca25 start + 1
28  ???                                 0x00000001 0x0 + 1
)

请建议我。怎么办?

2 个答案:

答案 0 :(得分:0)

错误告诉你

你有一个空/零的数组

之后你将删除一个对象项,该对象在该数组中不再存在

诀窍:快速修复搜索' removeObjectAtIndex '全部超出项目(从左上角的第3个搜索按钮)。如果找到一个/批次观察那些

答案 1 :(得分:0)

您可能无法在removeObjectAtIndex:内拨打viewWillDisappear:,但是您在-[TWMessageBarViewController statusBarHidden]内呼叫它。看那里,我想你会找到崩溃的根源!