数组计数抛出异常

0 iphone cocoa cocoa-touch objective-c

* - [__ NSArrayM count]:发送到解除分配的实例0x5edd5e0的消息

我正在获取此类异常并且崩溃了我的应用程序.代码是:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ 

 if(section == 0){
 return ([billDetials count]+ 1);
 }

 int rows = ([billers count] + 1);
  return rows;
}
Run Code Online (Sandbox Code Playgroud)

[billers count]对于这个声明,我得到了那个例外......这里的billers是NSMutableArray有6个对象.tableView由2部分组成.

所以我应该把数组计数为6,但它没有发生....

Ken*_*agh 6

听起来像billers数组没有得到妥善保留.确保它是保留属性,或者在创建该数组时正确保留它.

阅读并完全理解这一点:http: //developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html%23//apple_ref/doc/uid/10000011i