Does anyone have any examples they would like to share regarding the
Core Location framework in the SDK? I am in desperate need of help.
The only code that I can find is what is available on the iPhone Dev
website, which isn't much. I tried to implement the code into my
program but I get a error: "locationManager undeclared (first use in
this funciton".
Here is the code...
Core Location framework in the SDK? I am in desperate need of help.
The only code that I can find is what is available on the iPhone Dev
website, which isn't much. I tried to implement the code into my
program but I get a error: "locationManager undeclared (first use in
this funciton".
Here is the code...
Code:
#import "MyLocationGetter.h"
#import <CoreLocation/CoreLocation.h>
@implementation MyLocationGetter
- (void)startUpdates
{
// Create the location manager if this object does not
// already have one.
//ERROR is HERE!!!
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = 1000; // 1 kilometer
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
[locationManager startUpdatingLocation];
}
// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
// Disable future updates to save power.
[manager stopUpdatingLocation];
printf("latitude %+.6f, longitude %+.6f\n",
newLocation.coordinate.latitude,
newLocation.coordinate.longitude);
}
@end