我有一个TableView和基于数组的单元格。现在我想改变一个变量的基础上巫婆的数组显示在单元格中。UITableViewCell的内容
var array = ["first", "second", "third"]
var result = String
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let Cell = self.tableView.dequeueReusableCellWithIdentifier("CellID", forIndexPath: indexPath) as UITableViewCell
Cell.textLabel?.text = array[indexPath.row]
// and here I need the content of the Cell
switch Cell."content argument" {
case "first":
var result = "works"
case "second":
var result = "works also"
case "third":
var result = "what a surprise, works also"
default:
var result = "doesn't work"
}
return Cell
}
这里我需要参数来获取单元格的内容。并请,没有与“你必须创建一个新的文件或功能或扩展名”,不,只是参数请!
我相信你正在寻找 开关Cell.textLabel?.text –
你能详细说明你正在努力完成什么吗?你指的是什么论点和内容? Swift不支持你使用的对象“string”语法。另外,我建议不要使用大写变量名称,但这是另一个话题。 –
谢谢,但我曾尝试过,并没有工作,它给了我的错误代码'字符串'不能成为'字符串?'的成员。 – PascalCzasny