索引到函数数组:表达式解析为未使用的l值 [英] Indexing into array of functions: Expression resolves to an unused l-value

查看:111
本文介绍了索引到函数数组:表达式解析为未使用的l值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试索引函数数组,但我得到错误:表达式解析为未使用的l值。我试图谷歌这意味着什么,但信息是稀缺的,我发现似乎无关。有谁知道我在做错了什么?任何帮助将非常感激 !谢谢。

I am trying to index into an array of functions but I get the error: "Expression resolves to an unused l-value". I have tried to google what this means but information is scarce and what I find seems unrelated. Does anyone know what I am doing wrong here? Any help would be much appreciated ! Thank you.

 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()结果类似;你正在识别一个值,但实际上并没有用它做任何事情。

chartsArray[0] is analagous to writing just the result of lineChart(); you're identifying a value, but not actually doing anything with it.

这篇关于索引到函数数组:表达式解析为未使用的l值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆