开发者

CLLocation Manager Delegate is not getting called in iPhone OS 4.0

I have to run my app in iPhone OS 4.0. (in simulator).

-(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self newLocationUpdate];
}

-(void)newLocationUpdate
{
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];

}

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation 
{
    [locationManager stopUpdatingLocat开发者_开发百科ion];
}

In this CLLocationManager delegate method is not getting called. what changes should we make so that delegate method is called?


I'm suspecting that your "locationManager" instance is getting released prematurely.

Is it a property? If so, then change from:

locationManager = [[CLLocationManager alloc]] init];

to:

self.locationManager = [[CLLocationManager alloc] init];

and ensure the property is declared:

@property (nonatomic, retain) CLLocationManager * locationManager;

And don't forget to release it later, where appropriate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜