R.Ham R.Ham - 1 year ago 78
iOS Question

Swift: How to access a label in a custom cell within a certain tableView section

I have a custom

with a
. I want to be able to access this label at a certain
tableView section
e.g. section 3 and provide it a string to display without the use of an array and

Answer Source

You can catch it in cellForRowAtIndexPath override of a TableView

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("YourCustomCellRegisterName") as YourCustomCell
    if(indexPath.section == 3){
       cell.CellLabel.text = "foo"
    return cell
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download