【发布时间】:2016-01-15 04:11:30
【问题描述】:
var test = [String]()
var array = [String]()
override func viewDidLoad() {
super.viewDidLoad()
test = ["1", "2"]
var item = String()
var query:PFQuery = PFQuery(className: "Restaurant")
query.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
for object in objects! {
let data = object as PFObject
item = String(data["name"])
print(item)
self.array.append(item)
}
print(self.array)
print(self.array.count)
}
}
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel!.text = array[indexPath.row]
return cell
}
当我使用“测试”数组时,它可以显示出来。但是如果我要使用另一个数组,它不会显示任何内容。不确定是否正确添加了数组,但在输出中显示了数据。
这是打印的输出:
PerBacco
MACA Restaurant
["PerBacco", "MACA Restaurant"]
2
【问题讨论】:
-
你检查过其他数组的计数吗?
标签: ios swift parse-platform tableview