Ios NSObject内部的CLLLocationManager

Ios NSObject内部的CLLLocationManager,ios,objective-c,core-location,cllocationmanager,nsobject,Ios,Objective C,Core Location,Cllocationmanager,Nsobject,我正在尝试创建一个NSObject来获取位置和地址,我还将运行一些其他代码。我想把它放到我不同的应用程序中。我在更新位置时遇到问题。我有协议和委托工作,但我会张贴我的所有代码,试图让它清楚 在我的getLocation.h中 @protocol getLocationDelegate - (void)getLocation:(NSString *)address getLongitude:(CGFloat)longitude getLatitude:(CGFloat)latitude; @end

我正在尝试创建一个NSObject来获取位置和地址,我还将运行一些其他代码。我想把它放到我不同的应用程序中。我在更新位置时遇到问题。我有协议和委托工作,但我会张贴我的所有代码,试图让它清楚

在我的getLocation.h中

@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;
在我得到地址和位置后,我像这样调用协议,在我的getLocation.h中

[self.delegate getLocation:address getLongitude:longitude getLatitude:latitude];
在我要获取位置的.m文件中,这是代码

getLocation *location = [[getLocation alloc] init];
[location setDelegate:self];
[location getLocationInfo];
然后,当委托被调用时,我就有了我的方法

-(void)getLocation:(NSString *)address getLongitude:(CGFloat)longitude getLatitude:(CGFloat)latitude {
     // Do code after location and address has been returned
}

现在我的协议和代理正在工作,我的问题是我无法让locationManager开始更新。不确定发生了什么。

我明白了,ARC发布了
getLocation*location=[[getLocation alloc]init]在CoreLocation开始之前。所以我只需要在我的.h中声明它,让它变得强大

-(void)getLocation:(NSString *)address getLongitude:(CGFloat)longitude getLatitude:(CGFloat)latitude {
     // Do code after location and address has been returned
}