I am writing my first test app, and am having a few problems with it.
The app consists of a TabBar, currently with only 1 Tab, and a TableView. The TableView pushes new views into place when items are selected.
On the detail view there is a button to push a map view. This uses the MapView control.
The app works as expected, but will crash (exit) at random times when switching back and forth between the TableViews.
The app only seems to crash when on an actual device, it seems to work fine in the Simulator.
I have ran the app through Instruments using the Leaks option, and have fixed the couple of leaks that were in my code (I wasn't releasing things properly), but I still have the intermittent crash problem.
I have been moving through the TableView quite quickly, and was wondering if it is just me being impatient.
If anyone has any additional ways to try and solve this problem, the help would be appriciated.
If anyone has any additional ways to try and solve this problem, the help would be appriciated.
Is there any message in the console when the app crashes?
Search for NSZombies and the clang static analyzer. They're both tools that can help you find bugs in your code. It sounds like you may be releasing something *too* much now.
Is there any message in the console when the app crashes?
Search for NSZombies and the clang static analyzer. They're both tools that can help you find bugs in your code. It sounds like you may be releasing something *too* much now.
Thanks for your reply. I have no message in the console as the app doesn't crash in the simulator.
I will look for the tools you have suggested and give those a try. Are these tools a part of the SDK or are they downloaded from somewhere else? If they are additional downloads, would you be able to supply a link to where they can be got from?
Thanks,
Last edited by mgales; 07-07-2009 at 03:01 AM.
Reason: Clarification of reply
Thanks for your reply. I have no message in the console as the app doesn't crash in the simulator.
I will look for the tools you have suggested and give those a try. Are these tools a part of the SDK or are they downloaded from somewhere else? If they are additional downloads, would you be able to supply a link to where they can be got from?
Thanks,
You should still be able to see messages in the console, if you're running your app in the device directly from XCode.
Do you set a delegate for MKMapview? You should set the delegate property back to nil when you're done with it, otherwise it will keep calling methods on the delegate object even after the delegate object is destroyed.
Do you set a delegate for MKMapview? You should set the delegate property back to nil when you're done with it, otherwise it will keep calling methods on the delegate object even after the delegate object is destroyed.
That's exactly what's happening. Yesterday I had a VERY strange problem where a few seconds after backing out of a nav controller view, I'd crash with a call to a deallocated object.
After a lot of fussing around about NavController mishandling my view controllers, I realized that the deallocated object WAS the viewController I'd just popped. It was set as the delegate for a CLLocationManager object that was trying its darndest to report a new location.
Just telling it to stopUpdatingLocation in the controller's -(void)dealloc{ } was enough to stop the problem.
Just to give you my little experience: I had the same problem inside the the same navigation logic and had an autorelease in addNotation that gave me random errors.
Basically, set the MKMapView delegate to nil in dealloc.
mapView.delegate = nil;
I found that I also had to set
mapView.showsUserLocation = NO;
[mapView removeAnnotations:mapView.annotations];
If you're using location manager and its updating, set its delegate to nil in dealloc.
shomarim: Thanks for the link and suggestion. I was having the exact problem and setting the delegate to nil worked perfectly. I also followed your other suggestions, just in case. The problem was only occurring when the user (device or simulator) pressed the back button too fast, before the view fully loaded. Otherwise, I never experienced the issue. Thanks again!