Search code examples
iosswiftuitableviewcheckmark

how to access tableviewcell by indexpath in my function


I've got a tableview and I need to somehow save the ones that has been checked before. I've save the indexpath of those which has been check in an array. now I have the code below and I don't know how to define "cell" ( items are NSindexpath ). I've already tried this but it returns nill and doesn't work : let cell = super.tableView.cellForRowAtIndexPath(items)

override func viewWillAppear(animated: Bool) {

    for items in indexpatharray{
        if !indexpatharray.isEmpty{
        let cell = 

        cell!.accessoryType = UITableViewCellAccessoryType.Checkmark;
        cell!.selectionStyle = .None


    }

I've already tried this but it returns nill and doesn't work : let cell = super.tableView.cellForRowAtIndexPath(items)


Solution

  • If you need an access to cell, you can try this:

    let cell = tableView.cellForRowAtIndexPath(indexPath)