Reputation: 651
I am working on a UITableView inside a UIViewControlller and I would like to add a new cell to a row, but in a way that the only thing showing on the table would be the user defined name, but hidden data (such as a hyperlink) would be retained too. The purpose is to open such hyperlink when pressing the relative button.
I'm using
[dataSource addObject:UserDefineddName];
and this adds the name to the row, but how can I add the data too, without displaying it?
I have labels and a button set up in IB and I was thinking that perhaps the link could be assigned to a hidden label, but it's not clear to me how to do it.
Please advise! Many thanks
Upvotes: 0
Views: 65
Reputation: 3296
Create a class for your data with two properties, name
and url
. Then simply fill your data source with instances of this class instead of simply strings. In your cellForRowAtIndexPath
do something like this:
titleLabel.text = [dataSource objectAtIndex:indexPath.row].name;
Upvotes: 1