Reputation: 2042
What's the difference (if indeed there is a difference) between:
UITableViewCell *cell;
...
cell.textLabel.text = [self.adviceData objectAtIndex:indexPath.row];
and
UITableViewCell *cell;
...
NSString *text = [self.adviceData objectAtIndex:indexPath.row];
[cell.textLabel setText:text];
They both seem to do the same thing, but one has more brackets. Do the brackets do something?
Upvotes: 0
Views: 102
Reputation: 10265
The first one is just using the dot-notation syntax added in Objective-C 2.0. They both call the setText:
method on the textLabel
.
By the way, here's an article which will help you decide whether to use dot-notation syntax or not in your code.
Upvotes: 2
Reputation: 726809
They both do exactly the same thing, but the first one uses the alternative syntax for calling a setter (I'm ignoring the difference due to introduction of the NSString *text
variable). Behind the scene, the compiler generates identical code for the two calls.
Upvotes: 1