从 NSMutableArray 中的解析中检索数据
Retrieving data from parse in NSMutableArray
我正在 data
中检索数据。这是我的代码..
var data:NSMutableArray = NSMutableArray()
func loadData() {
data.removeAllObjects()
var findData:PFQuery = PFQuery(className: "Sweets")
findData.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error != nil {
println(error)
} else if let objects = objects {
for object in objects {
self.data.addObject(object)
}
var array:NSArray = self.data.reverseObjectEnumerator().allObjects
self.data = array as! NSMutableArray // Getting error here.. Could not cast value of type '__NSArrayI' (0x10391c420) to 'NSMutableArray' (0x10391c4e8).
self.tableView.reloadData()
}
}
}
请有人帮助我..我被困在这里,我是初学者。
按照如下正确的方式进行转换:
var findData:PFQuery = PFQuery(className: "Sweets")
findData.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error != nil {
println(error)
} else if let objects = objects {
for object in objects {
self.data.addObject(object)
}
var array:NSMutableArray = NSMutableArray(array: self.data.reverseObjectEnumerator().allObjects)
self.data = array as NSMutableArray
self.tableView.reloadData()
}
}
我正在 data
中检索数据。这是我的代码..
var data:NSMutableArray = NSMutableArray()
func loadData() {
data.removeAllObjects()
var findData:PFQuery = PFQuery(className: "Sweets")
findData.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error != nil {
println(error)
} else if let objects = objects {
for object in objects {
self.data.addObject(object)
}
var array:NSArray = self.data.reverseObjectEnumerator().allObjects
self.data = array as! NSMutableArray // Getting error here.. Could not cast value of type '__NSArrayI' (0x10391c420) to 'NSMutableArray' (0x10391c4e8).
self.tableView.reloadData()
}
}
}
请有人帮助我..我被困在这里,我是初学者。
按照如下正确的方式进行转换:
var findData:PFQuery = PFQuery(className: "Sweets")
findData.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error != nil {
println(error)
} else if let objects = objects {
for object in objects {
self.data.addObject(object)
}
var array:NSMutableArray = NSMutableArray(array: self.data.reverseObjectEnumerator().allObjects)
self.data = array as NSMutableArray
self.tableView.reloadData()
}
}