I don't understand the details of why and how to use selectors in objective -c. I understand that at runtime messages are 'converted' to selectors. But I don't understand why I should use them in practice. For example what is the purpose of calling the animateBall method in the initializerTimer method using a
selector?
-
Code:
(void)animateBall:(NSTimer *)theTimer {
ball.center = CGPointMake(ball.center.x +ballMovement.x,
ball.center.y + ballMovement.y);
}
-
Code:
(void)initializeTimer
{
float theInterval = 1.0/30.0;
[NSTimer scheduledTimerWithTimeInterval:theInterval target:self selector:@selector(animateBall:) userInfo:nil repeats: YES];
}