简体   繁体   中英

Crash when app enters foreground - because delegate = self?

my app is occassionaly crashing when it enters 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....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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