In tableView:cellForRowAtIndexPath:
I have the following:
cell.textLabel.text = @\"label\";
cell.detailTextLabel.text = @\"detail\";
Swift 3:
If you're making your cell with overriding the "cellForRowAt indexPath" function:
let tableContent = ["1", "2", "3", "4", "5"]
let tableDetailContent = ["a", "b", "c", "d", ""]
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: "yourCellIdentifier")
cell.textLabel?.text = tableContent[indexPath.row]
cell.detailTextLabel?.text = tableDetailContent[indexPath.row]
return cell
}
This code part from above allows you to set your detailTextLabel.. You can set whatever you want on storyboard for Table View Cell style (Custom, Basic, Right Detail, Left Detail, Subtitle), this line will override it:
style: UITableViewCellStyle.subtitle