Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Use the CLLocationManager
class:
if ([CLLocationManager locationServicesEnabled]){
self.myLocationManager = [[CLLocationManager alloc] init];
self.myLocationManager.delegate = self;
self.myLocationManager.purpose =
@"To provide functionality based on user's current location.";
[self.myLocationManager startUpdatingLocation];
} else {
/* Location services are not enabled.
Take appropriate action: for instance, prompt the
user to enable the location services */
NSLog(@"Location services are not enabled");
}
In this code, myLocationManager is a property of type
CLLocationManager. The current
class is also the delegate of the location manager in this sample
code.