Lawrence413
Lawrence413

Reputation: 2016

Access static cell when pressing button

My issue is pretty simple but I can't figure out how to do it. I have a static cell and a button inside it.

I have an IBAction hooked to the button.

How do I access the cell inside the IBAction?

I tried:

let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 2, inSection: 1) as myStaticCell
    cell.height = 200

But for an unknown reason to me, it takes both lines as a single expression.

Upvotes: 0

Views: 35

Answers (1)

Charles A.
Charles A.

Reputation: 11123

You are missing a closing parenthesis on the method call. Add a second ) before your as keyword. You will also need to use as!.

You need to change:

let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 2, inSection: 1) as myStaticCell

To this:

let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 2, inSection: 1)) as! myStaticCell

Upvotes: 1

Related Questions