Ios 在解析中获取匿名用户的位置?

Ios 在解析中获取匿名用户的位置?,ios,swift,parse-platform,swift2,parse-server,Ios,Swift,Parse Platform,Swift2,Parse Server,我正在尝试获取当前用户在解析中的位置。用户是匿名的,在AppDelegate中使用以下代码创建: //log in the anonymous user PFUser.enableAutomaticUser() PFUser.currentUser()!.incrementKey("RunCount") PFUser.currentUser()!.saveInBackground() PFGeoPoint.geoPointForC

我正在尝试获取当前用户在解析中的位置。用户是匿名的,在AppDelegate中使用以下代码创建:

//log in the anonymous user
        PFUser.enableAutomaticUser()
        PFUser.currentUser()!.incrementKey("RunCount")
        PFUser.currentUser()!.saveInBackground()

        PFGeoPoint.geoPointForCurrentLocationInBackground {

            (geoPoint: PFGeoPoint?, error: NSError?) -> Void in

            if let geoPoint = geoPoint {

                PFUser.currentUser()?["location"] = geoPoint

                PFUser.currentUser()?.saveInBackground()
            }
        }
用户已创建,但当我单步执行代码时,将跳过
PFGeoPoint.geoPointForCurrentLocationInBackground
块。为了保存匿名currentUser的位置,我还需要做其他事情吗


谢谢

您的应用程序是否有位置服务?您的应用程序中的设置下的示例是否启用了位置?Doh-就是这样!我所要做的就是将
nslocationwhenUsageDescription
添加到plist文件中。谢谢第一。当您使用自动用户时,Currentuser从不为零…其次,您如何知道代码停止?它不是在主线程上运行,需要几秒钟才能获得gps位置…请向上投票我的评论。