Retrieving an array from Parse.com

三世轮回 提交于 2019-12-25 08:19:18

问题


I am trying to download an array from Back4Apps.com (Parse.com equivalent). The below displays no errors, but when it gets to the line "downloadQuery.findObjectsInBackground { (objects, error) in", it simply skips over the rest of the code to the end of the function.

  • I have tested the "username" and it seems to be correct.
  • I am certain the class and subClass names are correct.
  • The parse parameters are correct and I already have many other parse functions working.

Any suggestions where to look?

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!)")
            }
        }
}

来源:https://stackoverflow.com/questions/41300287/retrieving-an-array-from-parse-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!