我使用的是Parse.com iOS SDK,我需要用户的当前位置,因此我使用了PFGeoPoint.geoPointForCurrentLocationInBackground(...)函数。
问题是:从不调用参数列表中的块。这是我的代码:
PFGeoPoint.geoPointForCurrentLocationInBackground() {
(point:PFGeoPoint!, error:NSError!) -> Void in
NSLog("Test log 1") // Never printed
if point != nil {
// Succeeding in getting current location
NSLog("Got current location successfully") // never printed
PFUser.currentUser().setValue(point, forKey: "location")
PFUser.currentUser().saveInBackground()
} else {
// Failed to get location
NSLog("Failed to get current location") // never printed
}
}
有什么想法吗?
答案 0 :(得分:17)
我遇到了同样的问题。它已在Parse 1.4.0中修复。
此外,您还需要将以下键/值对添加到您应用的info.plist中:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We want to send your location data to the NSA, please allow access to location services. (replace this text with whatever you want the dialog to say)</string>
参考文献:
答案 1 :(得分:3)
答案 2 :(得分:0)
检查一下:
点击您的项目目标/构建阶段/链接二进制文件库/
This file must be listed: CoreLocation.framework
if there is not click Add and select it from the list.
在ViewController.swift中查看:
导入CoreLocation
类ViewController:UIViewController,CLLocationManagerDelegate {
/ Supporting Files / info.plist&lt; - 点击此文件
点击+添加: 密钥:NSLocationAlwaysUsageDescription 类型:字符串 值:添加说明
点击+添加: 密钥:NSLocationWhenInUseUsageDescription 类型:字符串 值:添加说明
检查IOS模拟器 /调试/位置/苹果 在这里你必须选择一些东西(无=&gt;错误)