Retrieving an array from Parse.com

244 views Asked by At

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

There are 0 answers