Search code examples
iosxcodeswiftparse-platformpfquery

Parse query not loading in descending order


For some reason when I add an image to a tableView with Parse, it is pulling file from Parse fine, but is not loading in descending order...not sure why?

Thanks for any help!

class HomePageViewController: UIViewController, UITableViewDelegate {

@IBOutlet var homePageTableView: UITableView!

var albumImageFiles = [PFFile]()
var imageText = [String]()


override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    var query = PFQuery(className: "Posts")
    query.orderByDescending("createdAT")
    query.findObjectsInBackgroundWithBlock { (posts:[AnyObject]?, error: NSError?) -> Void in

        if error == nil {
            //success fetching objects


            for post in posts! {
               self.albumImageFiles.append(post["imageFile"] as! PFFile)
                self.imageText.append(post["albumText"] as! String)


            }


            /*reload the table*/
            self.homePageTableView.reloadData()



        } else {
            println(error)


        }

    }


}

Solution

  • query.orderByDescending("createdAT")
    

    should be

    query.orderByDescending("createdAt")