简体   繁体   中英

load UITableView from parse query

This code works part of the time,and other times it returns an empty array.I don't know why.I'm calling it in viewWillAppear .

func refreshFriendListFromLocalDatastore() {
    println("refreshing from local datastore")
    var friendRelations:PFRelation = currentUser.relationForKey("friendRelations") as PFRelation
    var query:PFQuery = friendRelations.query() as PFQuery
    query.orderByAscending("username")
    query.fromLocalDatastore()
    query.findObjectsInBackgroundWithBlock { (NSArray friends, NSError error) -> Void in
        if error == nil {
            self.friends = friends
            println("\(self.friends)")
            tableView.reloadData()
        } else {
            println("could not retrieve friend list at this time")
        }
    }
}

currentUser与使用pin固定到本地数据存储的用户没有朋友关系。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM