【发布时间】:2014-07-11 09:47:23
【问题描述】:
这是一个简单的UITableView 代码,在 Playground 中正常工作:
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() 的控制台输出:
游乐场执行失败:错误:错误:无法查找符号:_memmove
【问题讨论】:
-
MyDataSource() 方法的内容是什么?
-
@akashg 没有其他代码。你看到的是我所有的代码。
-
试试
list.dataSource = self -
@akashg
self在全局范围内显然是未定义的!
标签: ios uitableview swift swift-playground