View Hierarchy Recursion
Just a couple notes here, nothing earth shattering.
If you have a custom UITableViewCell with controls of some sort and you want to know in which cell a the value of a control changed, there are a few ways, one of which is bad, one of which is good.
bad:
UITableViewCell *cell = controlItem.superview;
This is dependent on the framework implementation at the time and in fact does not work for iOs 7 & 8. In those versions you would use:
controlItem.superview.superview
The fragility of this is obvious, especially if you’re not thinking and implement it on a custom UITableViewCell that has a different hierarchy.
A typically better way to approach the problem is some form of this:
- (UITableViewCell *)cellForControl:(UIControl *)control {
while (view != nil) {
if ([view isKindOfClass:[UITableViewCell class]]) {
return view;
}
view =
...