Question: I have 5 imageviews and I am updating them based on value but the problem is for updating all of them I have redundant code for eacg image updation expect the specific imageView object. Here is example, I have such 5 methods to update each imageview which I guess is not optimal solution. 

```
 public void imageThird(int value){
    third.setVisibility(View.VISIBLE);
    if(value >= 1000 && value <= 800) {
        third.setImageResource(R.drawable.sa);
    }
    else if(value >= 800 && value <= 500) {
        third.setImageResource(R.drawable.sb);
    }
    else if(value >= 500 && value <= 300) {
        third.setImageResource(R.drawable.sc);
    }
    else if(value >= 300 && value <= 150) {
        third.setImageResource(R.drawable.sd);
    }
    else if(value >= 150 && value <= 50) {
        third.setImageResource(R.drawable.se);
    }
    else {
        third.setImageResource(R.drawable.sa);
    }
}

```

So I have 5 like this method, which is not good I guess, the only difference is the imageview object for each image. May be it is silly question I am not much aware about how images works in Andorid.

Answer: 
I just tested it with a sample project. It works fine. There must be something wrong with your wiring up the cell. 

Here is my code. Only indicating changes from plain vanilla tab bar project template. 

![enter image description here](https://i.stack.imgur.com/fAKkQ.png)

```
// FirstViewController.swift
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 2
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell
    cell.textLabel?.text = "Cell \(indexPath.row + 1)"
    return cell
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let detail = segue.destinationViewController as DetailController
    let cell = sender as UITableViewCell
    let indexPath = self.tableView.indexPathForCell(cell)
    detail.detailItem = "Cell \(indexPath!.row + 1)"
}

//DetailController.swift
class DetailController: UIViewController {

    var detailItem : String!
    @IBOutlet var label : UILabel!

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        label.text = detailItem
    }
}

```
for calling the method prepareForSegue you must have to add a segue to connect the prototype cell and the destination Controller! method doesn't called if you navigate to destination controller programmatically!