通过视图中的特定类循环:Objective-c

Jam*_*nay 3 iphone xcode objective-c ios

我一直在使用以下代码遍历我的子视图中的特定类.

  for (int i = 0; i < [[self.view subviews] count]; i++) {
        if ([[self.view.subviews objectAtIndex:i] class] == [UIButton class]) {

        }
    }
Run Code Online (Sandbox Code Playgroud)

但我觉得应该有更好的方法.有人可以帮帮我吗?

谢谢.

Mar*_*off 9

for(UIView *v in [self.view subviews]) {
  if ([v isKindOfClass:[UIButton class]]) {
    ...
  }
}