- (int)indexOfView:(id)view {
for(int i = 0; i < self.subviews.count; ++i) {
UIView *v = [self.subviews objectAtIndex:i];
if(v == view) return i;
}
return -1;
}
This always returns -1. I suspect the problem is with v == view. Is that incorrect?
If it always returns -1, then it’s not in there.
But you should throw away a few lines of code:
NSArray and its methods are your friend. The
indexOfObject:method will returnNSNotFoundin stead of -1.If it’s a subclass of one of the contained views, then it won’t show up. Particularly if you’re dealing with an
NSTableViewCell.