Is it possible to start / stop location updates from the UI of the iphone? All I need from the app is to show me my location unless I click “stop” and then “start” again.
I can’t seem to be able to do that…I have my location displayed properly, and I also created two IBButtons and created a function for each of them, however, my app crashes when I click on each one of those buttons. I placed those functions under the viewcontroller.m.
I am kind of new to this, so any help would be appreciated. Thanks!
-
(IBAction)startUpdating: (CLLocation *)location
{[location startUpdatingLocation];
}
-
(IBAction)stopUpdating: (CLLocation *)location
{[location stopUpdatingLocation];
}
start/stopUpdatingLocation are
CLLocationManagerinstance methods, rather thanCLLocationinstance methods… so create aCLLocationManagerinstance..h
.m somewhere in the view load/ or init cycle:
also your action above will never work, because the thing after a colon in an action will be the object that sent the action, a UIButton in your case.