【发布时间】:2015-03-30 23:03:35
【问题描述】:
我正在尝试对函数数组进行索引,但出现错误:“表达式解析为未使用的左值”。我试图用谷歌搜索这意味着什么,但信息很少,而且我发现的似乎无关。有谁知道我在这里做错了什么?任何帮助将非常感激 !谢谢。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = myTableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
var chart = cell.contentView.viewWithTag(42) as TKChart
chart.delegate = self
chart.removeAllData(); //needed because of cell recycling
var userDef1 = 1
var userDef2 = 1
func lineChart() -> TKChart {...}
func columnChart() -> TKChart {...}
var chartsArray = [AnyObject]()
if userDef1 == 1{
chartsArray.append(lineChart())
}
if userDef2 == 1{
chartsArray.append(columnChart())
}
if indexPath.row == 0{
chartsArray[0] **error: Expression resolves to an unused l-value**
}
if indexPath.row == 1{
chartsArray[1] **error: Expression resolves to an unused l-value**
}
return cell
}
【问题讨论】:
-
chartsArray[i] 正在返回一个未被使用的值。 Swift 认为这是一个错误,因为没有使用 if 条件中唯一表达式的左侧值。