简体   繁体   English

将更多行加载到自定义表后,iPhone应用程序崩溃

[英]iphone app crashes after loading more row into a custom table

I am using a UITableView with custom cell. 我正在使用带有自定义单元格的UITableView。 I have an array that contains the objects of class A. In cellForRowAtIndexPath i go though the array and assign each object to each cell. 我有一个包含A类对象的数组。在cellForRowAtIndexPath中,我遍历该数组并将每个对象分配给每个单元格。 I first load 25 rows. 我首先加载25行。 Then when load more is pressed i load another 25 rows. 然后当加载更多被按下时,我加载另外25行。 When i move up and down i works fine. 当我上下移动时,我可以正常工作。 But problem happens when i load more 25 cells. 但是,当我加载更多25个单元格时,就会发生问题。 When i move to the top of the table the app crashes. 当我移到表格顶部时,应用程序崩溃。 I debugged the app and found that the object that i assign from the array has value of 0xffffffff which means there is nothing. 我调试了应用程序,发现我从数组分配的对象的值为0xffffffff,这意味着没有任何东西。 It always happens at the 4th cell of the table. 它总是在表格的第4个单元格处发生。 Can anyone help me out why this is happening ?? 谁能帮我解决为什么会这样吗?

thanx 谢谢

What are you seeing in the console? 您在控制台中看到了什么? Often it's a good hint, but if it's EXC_BAD_ACCESS, you need to worry about memory corruption. 通常,这是一个很好的提示,但是如果它是EXC_BAD_ACCESS,则需要担心内存损坏。

I have written this blog to understand crashes EXC_BAD_ACCESS and how to debug them. 我写了这个博客是为了了解崩溃EXC_BAD_ACCESS以及如何调试它们。

http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html

  1. Run Build and Analyze -- fix the problems it reports 运行构建和分析-修复报告的问题
  2. Run with Zombies enabled (instructions at link above) 在启用僵尸的情况下运行(上面链接中的说明)

Most problems are solved by doing those two things. 通过做这两件事可以解决大多数问题。 Otherwise Debug Malloc (also explained at the link) 否则,请调试Malloc(也在链接上说明)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM