您好,我可以查看此代码并已加载:
PFGeoPoint.geoPointForCurrentLocationInBackground { (geopoint: PFGeoPoint?, error: NSError?) -> Void in
if error == nil {
println(geopoint)
var user = PFUser.currentUser()
user["location"] = geopoint
var query = PFUser.query()
query!.whereKey("location", nearGeoPoint:geopoint!)
query!.limit = 10
query!.findObjectsInBackgroundWithBlock({ (users, error) -> Void in
var accepted = PFUser.currentUser()["accepted"] as! [String]
var rejected = PFUser.currentUser()["rejected"] as! [String]
for user in users {
错误是:
用户[“位置”] = 地理点
无法分配“PFGeoPoint”类型的值?为“AnyObject?”类型的值
这两行的下一个错误是相同的
var Accepted = PFUser.currentUser()["accepted"] as! [字符串] var returned = PFUser.currentUser()["rejected"] as! [字符串]
并且 AnyObject 无法转换为“[String]”
最后一个错误就行了
对于用户中的用户{
“[任何对象]?”没有名为“Generator”的成员 我希望你们能帮助我解决这些问题
最佳答案
您需要解开您的选项来访问它包含的引用(并调用它的方法)。
试试这个:
if let unwrappedUsers = users { for user in unwrappedUsers { ... } }
如果users
不为空/nil
/None
,它的引用将被解包到unwrappedUsers
。
关于string - 无法将类型 'GeoPoint?' 的值分配给类型 'AnyObject?' 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31799253/