ios - 索引到函数数组 : Expression resolves to an unused l-value

标签 ios swift

我正在尝试对函数数组进行索引,但出现错误:“表达式解析为未使用的左值”。我试图用谷歌搜索这意味着什么,但信息很少,而且我发现的似乎无关。有谁知道我在这里做错了什么?任何帮助将非常感激 !谢谢。

 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[0] 类似于仅编写 lineChart()结果;您正在确定一个值,但实际上并未对其执行任何操作。

关于ios - 索引到函数数组 : Expression resolves to an unused l-value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28253374/

相关文章:

html - iPad 上基于百分比的 CSS 布局中断

ios - iPhone x 上的 UITableViewController 顶部栏

swift - 没有请求的 Vapor 3 PostgreSQL CRUD http

swift - NSTableView 不会调用 viewForTableColumn

ios - 覆盖 View ,但将输入向下传播到最低 z-index

ios - 你能将 UIImage exif 数据复制到缩放后的 UIImage 中吗?

ios - 如何使用按钮在 Google ios sdk map 中设置放大和缩小

ios - UIWebView 中 WebSQL/SQLite 数据库的最大大小(phonegap)

ios - Swift - 从 CollectionViewCell 中的 UIButton 推送到 ViewController

ios - 在 Swift 中生成多页 PDF