I got a hard job to be done. I try to attach additional information to a UITableViewCell.
The tableViewCells got buttons inside that I subclassed to do that (I’m passing a NSString).
Now, when the user clicks on a tableRow, I want to fire an other method and want to pass the same string.
I created a subclass of UITableViewCell and added the string to it.
But I can’t get the value of the string in tableView:didSelectRowAtIndexPath:.
That’s because UITableView returns an UITableViewCell and not my custom subclass:
[tableView cellForRowAtIndexPath:indexPath].passString
→ /* Property 'passString not found on object of type UITableViewCell */
When I do NSLog(@"%@", [tableView cellForRowAtIndexPath:indexPath]); I can see the property on the log.
Now my question:
How can I get this subclass property in other methods?!
I don’t want to subclass UITableView as well. I’d end up subclassing like every UIElement I’m using :'(
Thanks for help, greetings
Julian
Jullian just type cast
UITableViewCellto your custom class likeor you can pass message instead of dot operator
[[tableView cellForRowAtIndexPath:indexPath] passString];it will give you warning but will work if it is the object of you CustomCell. Prefer using first method as I don’t like warnings in my code.