Creating a CLLocationManager class
The CLLocationManager
class is used to track both geolocation and proximity based on beacons. To start tracking beacon regions using the CLLocationManager
class, we need to do the following:
- Create an instance of
CLLocationManager
. - Assign an object conforming to the
CLLocationManagerDelegate
protocol to the delegate property. - Call the appropriate start method to begin the delivery of events.
All location- and heading-related updates are delivered to the associated delegate object, which is a custom object that you provide.
Defining a CLLocationManager class line by line
Consider the following steps to define a CLLocationManager
class line by line:
- Every class that needs to be notified about
CLLocationManager
events needs to first import the Core Location framework (usually in the header file) as shown:#import <CoreLocation/CoreLocation.h>
- Then, once the framework is imported, the class needs to declare itself as implementing the
CLLocationManagerDelegate...