【发布时间】:2014-02-24 00:47:52
【问题描述】:
我正在尝试在服务器更新时(理想情况下每 100 米)将用户位置发送到服务器,但现在我只是想让它工作。我对 iOS 7 很陌生,所以这可能并不像我想象的那么难……但这是我拥有的代码
-(void)sendUserLocationToServer
{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = 10; //kCLDistanceFilterNone; // whenever we move
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; // The best you can get
[self.locationManager startUpdatingLocation];
NSLog(@"HELLO. Latitude: %f longitude: %f", self.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude);
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"loactions %@", locations);
}
基本上,我有一个调用 sendUserLocationToServer 的方法来启动位置管理器,并且计划以某种方式使用 didUpdateLocations 方法,现在我只想注销该位置......但这就是我我到达那里后会拨打服务器电话。
在日志中,我看到了“HELLO”日志,但它从未归结为 didUpdateLocations 方法。
我错过了什么?
谢谢
编辑:不确定它是否有区别,但我在我的应用程序委托中有这个,它调用进程 pushPushNotificationData 方法
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)responseInfo{
NSLog(@"Received Notification: %@", responseInfo);
//Import the class header where the function is in this file (see above)
//Set class to variable
//Init the varibale / class
//Add the method you want to make public in the headerfile of responderViewController
XYZResponderViewController *responderController;
responderController = [[XYZResponderViewController alloc] init];
[responderController processPushNotificationData:responseInfo];
}
【问题讨论】:
标签: ios objective-c core-location