I am trying to load a view controller where the accelerometer is moving an image view. the error in the title shows and the app crashes upon view loading.
- (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);
}
}
}
}
The error shows on the line: for (UIView *image in self.wall) {
Please help!