为UITableView解析后端太慢了

时间:2015-02-19 17:42:07

标签: swift parse-platform

全部, 我已经得到了一些帮助,我很感激,但我仍然在努力让数据自动在tableview上查看。我正在努力找到我应该放在哪里

tableview.reloadData()

我可以通过拉下桌面视图来刷新它,它会直接进入,但它会自动显示..任何对这段代码都有新的看法..

var backgroundQueue:dispatch_queue_t =  dispatch_queue_create("SerialQueue", nil)

        var query = PFQuery(className:"TableViewData")
        query.includeKey("EventLoc")
        query.findObjectsInBackgroundWithBlock{
            (objects: [AnyObject]!, error: NSError!) -> Void in

            if error == nil {

                for object in objects {
                    dispatch_async(backgroundQueue, { () -> () in


                        let thumbNail = object["backgroundImage"] as PFFile

                        thumbNail.getDataInBackgroundWithBlock({
                            (imageData: NSData!, error: NSError!) -> Void in
                            if (error == nil) {
                                dispatch_async(dispatch_get_main_queue()) {
                                    let image = UIImage(data:imageData)
                                    self.CellBackgroundImage.append(image!)

                                }
                            }
                        })



                        let eventiconimage = object["EventIcon"] as PFFile
                        eventiconimage.getDataInBackgroundWithBlock({
                            (imageData: NSData!, error: NSError!) -> Void in
                            if (error == nil) {
                                dispatch_async(dispatch_get_main_queue()) {
                                    let image = UIImage(data:imageData)
                                    self.EventIconImageArray.append(image!)
                                }

                            }
                        })


                        var VenueLocation = object["EventLoc"] as PFObject!
                        VenueLocation.fetchIfNeededInBackgroundWithBlock {
                            (VenueLocation: PFObject!, error: NSError!) -> Void in
                            dispatch_async(dispatch_get_main_queue()) {
                                let VenueLocationTitle = VenueLocation["EventLocation"] as NSString
                                self.EventLocationArray.append(VenueLocationTitle)
                            }

                        }



                        dispatch_async(dispatch_get_main_queue()) {
                            self.TitleArray.append(object["EventTitle"] as String)
                            self.EventPriceArray.append(object["EventPrice"] as String)
                            self.EventStartDate.append(object["EventStartDate"] as NSDate)
                            self.EventEndDate.append(object["EventEndDate"] as NSDate)


                        }

                      self.tableView.reloadData()

这会使所有数据都被授予,但我不知道在哪里添加重新加载,因此它会引入,因为它第一次错过了。

谢谢

杰森

0 个答案:

没有答案