0
위치와 주소를 가져올 NSObject를 만들려고하고 있으며 다른 코드도 실행 중입니다. 나는 단지 그것을 다른 애플 리케이션에 버리고 싶다. 위치를 업데이트하는 데 문제가 있습니다. 프로토콜과 대리인이 작동하지만 모든 코드를 게시하여 명확하게하려고합니다. 내 getLocation.m에서 내 getLocation.hNSObject 내부의 CLLLocationManager
@protocol getLocationDelegate
- (void)getLocation:(NSString *)address getLongitude:(CGFloat)longitude getLatitude:(CGFloat)latitude;
@end
@interface getLocation : NSObject <CLLocationManagerDelegate> {
CGFloat latitude;
CGFloat longitude;
NSString *address;
}
@property (nonatomic, strong) id<getLocationDelegate> delegate;
@property (nonatomic, retain) CLLocationManager *locationManager;
- (void)getLocationInfo;
에서
- (id)init
{
if (self = [super init]) {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
}
return self;
}
- (void)getLocationInfo {
[self.locationManager startUpdatingLocation];
// This is being called but not starting the locationManager
}
나는 주소를 확인하고 위치를 내 getLocation.h
,이 같은 프로토콜을 호출 한 후[self.delegate getLocation:address getLongitude:longitude getLatitude:latitude];
위치를 얻으려는 내 .m 파일의 코드는
입니다. 대리인이 이제 내 프로토콜과 대리인이 내 문제는 내가 업데이트를 시작을 locationManager를 얻을 수없는 어떤 작업-(void)getLocation:(NSString *)address getLongitude:(CGFloat)longitude getLatitude:(CGFloat)latitude {
// Do code after location and address has been returned
}
을 호출 될 때 6,
getLocation *location = [[getLocation alloc] init];
[location setDelegate:self];
[location getLocationInfo];
은 그 때 나는 내 방법이있다. 무슨 일인지 잘 모르겠다.