Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIRefreshControl崩溃应用程序Parse.com查询_Ios_Swift_Uicollectionview_Uirefreshcontrol - Fatal编程技术网

Ios UIRefreshControl崩溃应用程序Parse.com查询

Ios UIRefreshControl崩溃应用程序Parse.com查询,ios,swift,uicollectionview,uirefreshcontrol,Ios,Swift,Uicollectionview,Uirefreshcontrol,我有一个带有UIRefresh控件的UICollectionView。UIRefreshControl运行查询以从Parse.com获取对象。当我通过下拉执行刷新时,会导致应用程序崩溃并显示以下消息: fatal error: Cannot index empty buffer 但是,当我按下按钮或在ViewDidLoad中运行相同的刷新代码时,它不会崩溃,并根据需要执行查询。这是否意味着拖动代码而不是刷新代码有问题 下面是刷新代码,它与self.refreshControl.endRefre

我有一个带有UIRefresh控件的UICollectionView。UIRefreshControl运行查询以从Parse.com获取对象。当我通过下拉执行刷新时,会导致应用程序崩溃并显示以下消息:

fatal error: Cannot index empty buffer
但是,当我按下按钮或在ViewDidLoad中运行相同的刷新代码时,它不会崩溃,并根据需要执行查询。这是否意味着拖动代码而不是刷新代码有问题

下面是刷新代码,它与self.refreshControl.endRefreshing的定位有关吗


你能告诉我们当刷新控件激活时执行的代码吗?我已经添加了上面的代码。
func refresh(sender:AnyObject)
{

    println("Refresh")

    self.orderedIdArray = []

    self.idArray = []
    self.organizerNameArray = []
    self.categoryNameArray = []
    self.classNameArray = []

    var query = PFQuery(className:"Rides")
    query.orderByAscending("date")
    query.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]!, error: NSError!) -> Void in
        if error == nil {
            // The find succeeded.
            NSLog("Successfully retrieved \(objects.count) scores.")
            // Do something with the found objects


            for object in objects {
                NSLog("%@", object.objectId)

                var testId = object.objectId

                println(testId)


                self.orderedIdArray.append(testId)

                var query = PFQuery(className:"Rides")
                query.getObjectInBackgroundWithId(testId) {
                    (gameScore: PFObject!, error: NSError!) -> Void in

                    if error == nil {



                        NSLog("%@", gameScore)

                        //Gets the Values from Parse.com

                        self.organizerNameString = gameScore["organizer"] as String

                        self.categoryNameString = gameScore["category"] as String

                        self.classNameString = gameScore["class"] as String

                                self.organizerNameArray.append(self.organizerNameString)
                                self.categoryNameArray.append(self.categoryNameString)
                                self.classNameArray.append(self.classNameString)

                                self.idArray.append(object.objectId)
                                NSLog("%@", self.idArray)

                            } else {
                                println("Do not add to the array")

                            }
                    }   
                    } else {
                        NSLog("%@", error)
                    }
                    self.collectionView?.reloadData()
                }
            }

        } else {
            // Log details of the failure

            NSLog("Error: %@ %@", error, error.userInfo!)

        }
        self.refreshControl.endRefreshing()

        NSLog("Ordered: %@", self.orderedIdArray)
    }
    println("Completed the query")

}