Reputation: 3227
I am looking for a way to identify a subview object while iterating inside a for-loop, I basically get all subviews from a UITableView's contentView by doing cell.contentView.subviews.
for SubView in cell.contentView.subviews {
// check if it's the correct subview
}
basically thats how I get the subview objects into a loop, while I can see that I got multiple objects in there I need to somehow identify these, in C# a key named simply as name is defined as such:
object.name = "something"
and then retreived in a for-loop by:
object.name
but this doesn't seem to be a possibility in Swift, how would I go about identifying an object if I got multiple occurrences of let's say a UILabel?
Upvotes: 0
Views: 592
Reputation: 6494
There is the tag
property on UIView, although it's an integer and not a string. But you could use an enum to make it readable.
Upvotes: 1