繁体   English   中英

使用Parse SDK获取当前位置

[英]Getting Current Location using Parse SDK

我正在尝试使用geoPointForCurrentLocation方法中的构建获取用户的当前位置。 我尝试在我的User类(称为location)中创建的自定义字段中设置geoPoint,然后尝试使用saveInBackground方法保存它。

[PFGeoPoint geoPointForCurrentLocationInBackground: ^(PFGeoPoint *geoPoint, NSError *error) {
    if (!error)
    {                
        [[PFUser currentUser] setObject: geoPoint forKey: @"location"];                
        [[PFUser currentUser] saveInBackground];                
    }            
}];

没有引发任何错误,但用户的位置未保存到数据库。

编辑:

我的viewDidLoad方法看起来像这样:

self.locationManager = [[[CLLocationManager alloc] init]; self.locationManager.delegate =自我;

if ([self.locationManager
    respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
    [self.locationManager requestWhenInUseAuthorization];
} 

}

并且我为使用授权设置了info.plist密钥。

没有用CLLocationManagerDelegate标记我的实现文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM