mrd*_*enz 5 iphone exc-bad-access uitableview ios
我的UITableView正在返回EXEC_BAD_ACCESS,但为什么!
看到这段代码片段!
加载UITableView工作正常,所以allXYZArray != nil并填充!
然后将tableview滚动到底部并备份导致它崩溃,因为它重新加载方法cellForRowAtIndexPath
它失败了:
"NSLog(@"allXYZArray::count: %i", [allXYZArray count]);"
(UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAt
IndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
@try
{
if (allXYZArray == nil) {
NSLog(@"nil");
allXYZArray = [ToolBox getMergedSortedDictionaries:allXYZGiven SecondDictionary:allXYZSought];
}
NSLog(@"%i", [indexPath row]);
NSLog(@"allXYZArray::count: %i", [allXYZArray count]);
Run Code Online (Sandbox Code Playgroud)
cdu*_*uhn 10
EXC_BAD_ACCESS表示您的程序正在尝试访问无效或无法从您的进程访问的内存地址.当您尝试向已经解除分配的对象发送消息时,通常会发生这种情况.因此,调试EXC_BAD_ACCESS的第一步是确定程序尝试向崩溃发生时发送消息的对象.通常答案并不明显,在这种情况下,NSZombieEnabled是一个很好的工具,用于识别导致崩溃的代码行.
在你的情况下,你已经确定当你打电话时发生了崩溃[allXYZArray count],这使allXYZArray我们成为主要的嫌疑人.此对象正在返回+[ToolBox getMergedSortedDictionaries:SecondDictionary:],因此您的错误很可能是在该方法的实现中.我猜它会返回一个已经被释放的对象而不是自动释放的对象,正如Cocoa的内存管理编程指南所规定的那样.(顺便说一句,这是SDK中最重要的文档之一.我建议每月重读一次,直到其政策和技术成为第二天性.)
| 归档时间: |
|
| 查看次数: |
6302 次 |
| 最近记录: |