Reputation: 6166
I am creating sample hello world application. The code is below. How can i removed the
warning at c[cell setText:@"Hello World"]; in the code below as it deprecated.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell setText:@"Hello World"];
Upvotes: 12
Views: 19910
Reputation: 2037
UITableViewCell textLabel is deprecated now.
iOS 15+ should use:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: "acme")
var content = cell.defaultContentConfiguration()
content.text = "Hello World"
cell.contentConfiguration = content
return cell
}
Upvotes: 0
Reputation: 49
There's also more Objective-C way of doing that:
[[cell textLabel] setText:@"Hello World"];
and detail label text:
[[cell detailTextLabel] setText:@"Hello World"];
Upvotes: 3
Reputation: 2241
set cell label text
cell.textLabel.text = @"Hello World";
and detail label text
cell.detailTextLabel.text = @"yourText";
Upvotes: 25