didUpdateToLocation is not called

橙三吉。 提交于 2019-12-06 06:09:16

Are location services for your application enabled?

P.S: it would help to make your location manager an instance variable so it will be retained by ARC after the method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions is completed.

I realize this is a necro, but I searched high and low for an answer on this and couldn't find a solution for my similar situation, this seems like the best spot for it.

I made a Delegate object with a custom initializer that sets some flags then runs [self->locationManager startUpdatingLocation], and invoke it as such in a viewDidLoad:

myLocationGetter* __unused getter = [[myLocationGetter alloc]initAndUpdateOnce;

Neither didUpdateToLocation nor didFailWithError was getting called. Seems like ARC was forgetting about my getter object before the callbacks came through. Solved the problem by declaring getter as an instance var in the view controller and initializing it in viewDidLoad.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!