简体   繁体   English

为什么我在 cellForRowAtindexpath 中遇到崩溃?

[英]Why am I experiencing a crash in cellForRowAtindexpath?

I had uploaded my app to the App Store but it was rejected two times, with the reason being that the app is crashing on iPhone 4 (iOS 4.3.5).我已将我的应用程序上传到 App Store 但两次被拒绝,原因是该应用程序在 iPhone 4 (iOS 4.3.5) 上崩溃。 I have tested my app on the same version but I can't make it crash.我已经在同一版本上测试了我的应用程序,但我无法让它崩溃。

My app is getting user location for drawing a path on g-map.我的应用程序正在获取用户位置以在 g-map 上绘制路径。 I have also tested with location service enable/disable, wifi on/of.我还测试了位置服务启用/禁用、wifi 开/关。 For all these ways I have tested, my app is not crashing.对于我测试过的所有这些方式,我的应用程序没有崩溃。 After symbolicating my last crash report I have found location and that is in cellForRowAtindexpath :在符号化我上一次崩溃报告后,我找到了位置,即在cellForRowAtindexpath中:

if([finalarray count]>0)
{
    cell.shopnamelbl.text=[[finalarray objectAtIndex:indexPath.row] valueForKey:@"name"];
    cell.distancelbl.text=[NSString stringWithFormat:@"%@km",[[finalarray objectAtIndex:indexPath.row] valueForKey:@"distance"]];
}

else if([unsortedarray count]>0)
{

    cell.shopnamelbl.text=[[unsortedarray objectAtIndex:indexPath.row] valueForKey:@"name"];
    cell.distancelbl.text=@"";      
}
else 
{
    cell.shopnamelbl.text=@"Loading...";
    cell.distancelbl.text=@"";
}

return cell;

in above code on cell.shopnamelbl.text=@"Loading...";在上面的代码中cell.shopnamelbl.text=@"Loading..."; this line is the cause of my crash, but in my testing everything works perfectly.这条线是我崩溃的原因,但在我的测试中,一切正常。 I am not seeing a crash anywhere else in my app.我在我的应用程序的其他任何地方都没有看到崩溃。

So now what can I do to fix this?那么现在我能做些什么来解决这个问题呢?

There's nothing obviously wrong with the code you've posted, so it's likely to be some other difference between what you've been testing and what Apple have on their handsets.您发布的代码没有明显的问题,因此您测试的代码与苹果手机上的代码可能存在其他差异。

On first run, their device will have nothing in NSUserDefaults set, nothing in the keychain, nothing in the Documents directory.在第一次运行时,他们的设备在NSUserDefaults设置中没有任何内容,在钥匙串中没有任何内容,在 Documents 目录中没有任何内容。 You need to completely wipe your device of any trace of previous runs of your app.您需要彻底清除设备上之前运行应用程序的任何痕迹。 Deleting and re-installing isn't enough.删除并重新安装是不够的。

It might also be worth trying on a number of devices.在许多设备上尝试也可能是值得的。 It's possible that you've inadvertently made some assumptions about how long certain operations take which don't hold on the faster/slower/different handsets that Apple uses for testing.您可能无意中对某些操作需要多长时间做出了一些假设,这些假设不适用于 Apple 用于测试的更快/更慢/不同的手机。

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

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