In Objective-C, what does "(UIButton *)sender" mean and why is it not "UIButton *sender"? Or some NSObject in place of UIButton. This is more a question about the precedence of the asterisk...
- (IBAction)digitPressed:(UIButton *)sender {
//...
}
In Objective-C, what does "(UIButton *)sender" mean and why is it not "UIButton *sender"? Or some NSObject in place of UIButton. This is more a question about the precedence of the asterisk...
- (IBAction)digitPressed:(UIButton *)sender {
//...
}
It's not about precedence in this case. The parentheses aren't a cast.
This is the syntax in ObjC for a method declaration, and it says that the parameter called sender is of type UIButton *.
The asterisk goes with the UIButton because they together name the type of the argument. In this case, since it's an action method coming from a button, you're using a UIButton*. In the general case, of course, a method may have parameters of any type, as long as the caller is calling it correctly. :)