Indexing into array of functions: Expression resolves to an unused l-value

前端 未结 2 982
陌清茗
陌清茗 2021-01-20 13:29

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

2条回答
  •  有刺的猬
    2021-01-20 13:48

    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]()  
        }
    
    
        if indexPath.row == 1{
            chartsArray[1]()   
        }
    
         return cell
    }
    

提交回复
热议问题