我有一个有几个PFObjects的关系。我想查询这个关系并将所有对象放入一个数组中。然而,我的代码似乎没有做到这一点,所以我希望得到一些帮助。
代码:
var requestsQuery = PFQuery(className: "Requests")
requestsQuery.whereKey("requested", equalTo: PFUser.currentUser()!)
requestsQuery.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
if let objects = objects as? [PFObject] {
for object in objects {
usernames.append(object["requesterUsername"] as! String)
receivedOffers.append(object["cardsOffered"] as! [AnyObject])
//ERROR HERE: Could not cast value of type 'PFRelation' (0x13c3c8) to 'NSArray' (0x38a26ab8).
receivedRequests.append(object["cardsRequested"] as! [AnyObject])
}
}
} else {
println(error)
}
self.tableView.reloadData()
}