Q:

How to stop location updates from another class/view?

I'm currently building an app that allows the user to keep track of the various "trips" they make.
The app consists of two views. The first view consists of 2 buttons that allow the user the start & stop the current "trip".
Pressing the start button segues into the second view which essentially displays the current trip on a map.
The issue I have is stopping the trip. When the user wishes to stop the trip, they should simply hit the stop button in the first view. I would like to then stop the location updates as they are no longer needed.
The issue is that the location manager is inside the second view so I cannot call the stopLocationUpdates method from the first view.
What I've tried:
I've setup an NSNotification to tell the second view to stop the location updates. The issue is that this only gets called upon the second view being loaded again. This is useless as upon stopping the trip, the second view will never get loaded (not until another trip is started).
Thanks in advance for any help.

A:

First of all, NSNotification has absolutely no clue about the state of view controllers at all. So if it starts listening only on load, it's probably because you start listening for notifications on load. You can do that in the designated initializer as well, which might solve your problem.
However, maybe you want to re-consider deleting the view controller all together? If it is not used at all, then why keep it in memory in the first place? You could simply release it.

