简体   繁体   English

为什么多次触摸会导致我的iPhone应用程序崩溃?

[英]Why are multiple touches causing my iPhone app to crash?

In my app, I am getting the row index as the user taps on the row or selected row. 在我的应用程序中,当用户点击行或选定行时,我得到行索引。 But if a row is tapped twice, my app crashes. 但如果一行被点击两次,我的应用程序崩溃了。

What could be causing this behavior, and how can I fix it? 可能导致此行为的原因,我该如何解决? Here's the code I'm using: 这是我正在使用的代码:

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

    abc *xyz = [[abc alloc] init];
    dcs = [allHadits objectAtIndex:indexPath.row];
    hk = dcs.kokid;
    [dcs release];
}

Do you mean tapping on the same row twice makes it crash? 您是说两次敲击同一行会使其崩溃吗? If so, it might be because of the [dcs release] . 如果是这样,可能是因为[dcs release] I don't know what dcs is (unless that's supposed to be xyz) but grabbing a pointer to the object in the array and then calling release on it might be releasing the object in the array, making it crash next time the row is hit. 我不知道dcs是什么(除非应该是xyz),但是抓住指向数组中对象的指针然后调用release可能会释放数组中的对象,从而在下次单击该行时使其崩溃。 Delete the [dcs release] and see if it still crashes. 删除[dcs release]并查看它是否仍然崩溃。 My memory management isn't the greatest though so I could be wrong. 我的内存管理不是最好的,所以我可能是错的。

Don't release dcs. 不要发布DC。 Why are your variables named so poorly? 为什么你的变量命名如此之差?

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

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