clubComments.removeAllObjects()
let findClubCommentData:PFQuery = PFQuery(className: "testObject")
findClubCommentData.findObjectsInBackgroundWithBlock {
(objects:[PFObject]?, error:NSError?) -> Void in
if (error == nil && objects != nil) {
for object:PFObject! in objects!{
self.clubComments.addObject(object)
}
let array: NSArray = self.clubComments.reverseObjectEnumerator().allObjects
self.clubComments = array as! NSMutableArray
self.tableView.reloadData()
从此代码中获取错误...有关如何解决此问题的任何建议?我卡住了......
答案 0 :(得分:0)
在Swift中始终使用本机集合类型,它可以避免这些错误。例如,Swift数组的函数reverse()
比reverseObjectEnumerator().allObjects
将clubComments
声明为
var clubComments = [PFObject]()
然后尝试
clubComments.removeAll()
let findClubCommentData = PFQuery(className: "testObject")
findClubCommentData.findObjectsInBackgroundWithBlock {
(objects:[PFObject]?, error:NSError?) -> Void in
if error == nil {
self.clubComments = objects!.reverse()
self.tableView.reloadData()
}
}