カスタムクラスは「didUpdateToLocation」CLLocationManagerDelegateメソッドを受け取る必要がありますが、次のコードを機能させることができないようです。
ヘッダーファイル。
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface MyCurrentLocation : NSObject<MKAnnotation,CLLocationManagerDelegate,MKMapViewDelegate>
{
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) CLLocationManager *locationManager;
-(MyCurrentLocation *)init;
@end
実装ファイル。
#import "MyCurrentLocation.h"
@implementation MyCurrentLocation
-(BLCurrentLocation *)init
{
self = [super init];
if (self) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.distanceFilter = kCLDistanceFilterNone;
_locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
[_locationManager startUpdatingLocation];
}
return self;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"Did we receive a location?");
}