我正在尝试从 Back4Apps.com(Parse.com 等效)下载一个数组。下面显示没有错误,但是当它到达“downloadQuery.findObjectsInBackground { (objects, error) in”行时,它只是跳过其余代码到函数末尾。
- 我已经测试了“用户名”,它似乎是正确的。
- 我确定类和子类名称是正确的。
- 解析参数是正确的,我已经有许多其他解析函数在工作。
有什么建议去哪里看吗?
var userCommonNameArray = [String]()
var userCommonNameESArray = [String]()
var userCommonNameFRArray = [String]()
var userCommonNameDEArray = [String]()
var speciesNameArray = [String]()
var userNotesArray = [String]()
func insertFromParse () {
let username = userDefault.value(forKey: "username") as! String
let downloadQuery = PFQuery(className:"ReefLifeApps")
downloadQuery.whereKey("username", equalTo: username)
// This is there Xcode skips from to the end
// tried variations of the below line. Neither worked.
// downloadQuery.findObjectsInBackground {(objects, error) -> Void in
downloadQuery.findObjectsInBackground { (objects, error) in
if error == nil {
// Do something with the found objects
for object in objects! {
self.userCommonNameArray.append(object.object(forKey: "userCommonName") as! String)
self.userCommonNameESArray.append(object.object(forKey: "userCommonNameES") as! String)
self.userCommonNameFRArray.append(object.object(forKey: "userCommonNameFR") as! String)
self.userCommonNameDEArray.append(object.object(forKey: "userCommonNameDE") as! String)
self.speciesNameArray.append(object.object(forKey: "speciesName") as! String)
self.userNotesArray.append(object.object(forKey: "userNotes") as! String)
}
} else {
print("Error: \(error!)")
}
}
}