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). 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. I have also tested with location service enable/disable, wifi on/of. 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
:
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...";
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. 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.
精彩评论