If you need to get the device location in multiple sections of the app CLLocationManager may be a solution. CLLocationManager is a wrapper to avoid using multiple CLLocationManager across an application. All delegates added to IKLocation are notified when the location is available or when the refresh method is called. IKLocation automatically removes object when those are deallocated.
For questions or general comments regarding the use of this library, please use our public hipchat room.
If you find any bugs or have a problem while using this library, please open an issue in this repo (or a pull request :)).
And you can check all of our open-source projects at inaka.github.io
- Copy
IKLocation.handIKLocation.mto your project. (or you can just add it as a pod.pod 'IKLocation') - Call
[IKLocation sharedClient]when you want your app to prompt the user to allow access location. - Implement
IKLocationDelegate - Add all the objects that implements the delegate.
[[IKLocation sharedLocation] setDelegate:self]; - Implement
ikManager:didUpdateToLocation:fromLocation:and if you wantikManagerDidFailWithError:
You can add as many delegates as you want. The wrapper is using a NSPointerArray to avoid reference cycles.
The app also exposes the following properties:
- location:
(CLLocation *)Current location - oldLocation:
(CLLocation *)Previous location - latitude:
(CGFloat)Current latitude - longitude:
(CGFloat)Current longitude - city:
(NSString *)Current city - state:
(NSString *)Current state - country:
(NSString *)Current country
The app also exposes the following methods:
- isLocationAvailable: Returns true if a location is available.
- refresh: Updates the location.