Ios &引用;CountByEnumerating with state:objects:count:;错误

Ios &引用;CountByEnumerating with state:objects:count:;错误,ios,xcode,semantics,Ios,Xcode,Semantics,我试图加载一个视图控制器,其中加速计正在移动图像视图。标题中的错误会显示,并且在加载视图时应用程序会崩溃 - (void)collsionWithWalls { CGRect frame = self.Mover.frame; frame.origin.x = self.currentPoint.x; frame.origin.y = self.currentPoint.y; for (UIView *image in self.wall) {

我试图加载一个视图控制器,其中加速计正在移动图像视图。标题中的错误会显示,并且在加载视图时应用程序会崩溃

- (void)collsionWithWalls {

    CGRect frame = self.Mover.frame;
    frame.origin.x = self.currentPoint.x;
    frame.origin.y = self.currentPoint.y;

    for (UIView *image in self.wall) {

        if (CGRectIntersectsRect(frame, image.frame)) {

            // Compute collision angle
            CGPoint MoverCenter = CGPointMake(frame.origin.x + (frame.size.width / 2),
                                               frame.origin.y + (frame.size.height / 2));
            CGPoint imageCenter  = CGPointMake(image.frame.origin.x + (image.frame.size.width / 2),
                                               image.frame.origin.y + (image.frame.size.height / 2));
            CGFloat angleX = MoverCenter.x - imageCenter.x;
            CGFloat angleY = MoverCenter.y - imageCenter.y;

            if (abs(angleX) > abs(angleY)) {
                _currentPoint.x = self.previousPoint.x;
                self.MoverXVelocity = -(self.MoverXVelocity / 2.0);
            } else {
                _currentPoint.y = self.previousPoint.y;
                self.MoverYVelocity = -(self.MoverYVelocity / 2.0);
            }

        }

    }

}
错误显示在行上: 用于(UIView*self.wall中的图像){


请帮助!

对于in语句语法:

for (UIView *image in self.wall) ...
应理解为“对于每个对象,我们将其视为指向
UIView
的指针,并在集合
self.wall
中调用
image
,do…”.从您所说的,
self.wall
不是集合。它是一个
UIImageView
。这就是错误的原因。您正在编写一个需要集合的语句,但您没有提供集合


那么,为什么在这里使用for循环?没有什么可循环的。您是想使用其他表达式来计算集合,而不是
self.wall

显示完整的错误消息。
self.wall
的数据类型是什么?墙是我希望移动器反弹的图像。错误显示:集合表达式类型“UIImageView*”可能不响应“CountByEnumerating with state:objects:count:”可能需要
for(self.wall.animationImages中的UIImage*图像)