Crash when app enters foreground - because delegate = self?
my app is occassionaly crashing when it enters开发者_如何学Python the foreground. It doesn't always happen, but I think I've managed to isolate what is causing it. I am using this line:
self.locationManager.delegate = self;
Where self.locationManager is a retained property. When I comment this line out, the app can repeatedly come into the foreground and not crash.
I dont really understand what happens to viewcontrollers when they go into the background or come into the foreground.
Any ideas?
I managed to fix it now.
I added this line to the dealloc method of the viewcontroller:
self.locationManager.delegate = nil;
That seemed to sort it out....
精彩评论