I want to access cell of tableView from outside tableView func, for example in this case I want to access from a IBAction Func, then I have created tableView object and IndexPath object, when I running my project the Xcode shows me this error:
Fatal error: unexpectedly found nil while unwrapping an Optional values
for this line: mytableView!.cellForRowAtIndexPath(indexPath!)
@IBAction func editButtonFunc(sender: AnyObject) {
mytableView!.cellForRowAtIndexPath(indexPath!)
let cell =
mytableView!.dequeueReusableCellWithIdentifier(
"mycell", forIndexPath: indexPath!)
as! profileTableViewCell
cell.contentOutlet.text = contentItems[indexPath!.row]
cell.contentOutlet.textAlignment = NSTextAlignment.Right
cell.contentOutlet.font = UIFont(name: "X Yekan", size: 18)
}
cellForRowAtIndexPath
returns nil then no cell is currently available for that index path and you should just move on. – Paulw11