Reputation: 6705
I'm having trouble making sense of the following:
UILabel *label = (UILabel *)[cell viewWithTag:1000];
I understand that UILabel
is a class. So we're creating a pointer named *label
that points to an instance of UILabel
.
Right of the equals sign, I understand that [cell viewWithTag:1000];
is passing cell
a method named viewWithTag
with the argument 1000
.
What does the (UILabel *)
before that mean?
Upvotes: 0
Views: 155
Reputation: 14401
It is casting the result to a UILabel
. The syntax is the same as in C - (Objective-C is a super-set of C).
You can also check the type before using it (although not really necessary if you are confident of what is being returned) using isKindOfClass
Upvotes: 1
Reputation: 17732
It means to cast the object type to a UILabel*
. By default, viewWithTag:
returns a UIView*
Upvotes: 2