【发布时间】:2015-06-26 04:15:06
【问题描述】:
我正在尝试让我的代码在应用加载时使用用户当前时间和位置更新我的解析数据库。这是我当前的代码:
- (void)viewDidLoad {
[super viewDidLoad];
PFObject *testObject = [PFObject objectWithClassName:@"TestObject"];
testObject[@"foo"] = @"bar";
// PFGeoPoint *point = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0];
// testObject[@"location"] = point;
[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
if (!error) {
testObject[@"location"] = geoPoint;
}
}];
[testObject saveInBackground];
当我给它一个预设的经纬度和经度以供使用时,我的数据库会正确更新,但是当我使用解析代码来获取用户 geoPoint 时它不起作用。这是因为我做错了还是因为当我在我的电脑上使用 iPhone 模拟器时它不起作用。谢谢。
【问题讨论】:
-
你在获取位置之前保存了
testObject,把它写在完成块中
标签: ios xcode parse-platform geolocation cllocationmanager