这是一个在操场上正常工作的简单UITableView
代码:
import UIKit
class MyDataSuorce : NSObject, UITableViewDataSource {
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell = UITableViewCell(style: .Value2, reuseIdentifier: nil)
cell.textLabel.text = "Row #\(indexPath.row)"
return cell;
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return 4
}
}
let list = UITableView(frame:CGRectMake(0,0,300,300), style: .Plain)
let d = MyDataSuorce()
list.dataSource = d
list.reloadData()
但是当我第一次尝试这段代码时,它不起作用,只显示一个空的UITableView
:
let list = UITableView(frame:CGRectMake(0,0,300,300), style: .Plain)
list.dataSource = MyDataSuorce()
list.reloadData()
第二个代码有什么问题?
编辑:
这是控制台输出list.dataSource = MyDataSuorce()
:
Playground 执行失败:错误:错误:无法查找符号:_memmove