Reputation: 16134
I have a best practices/stylistic question. Let's say I have an IBAction method and I have no need for the sender parameter (I'm aware how to use the sender parameter if I do need it). Do folks recommend leaving the (id)sender in the method declaration for consistency, or exclude it for brevity? Functionally, there is no right answer here, just curious about what folks consider best practice for maintainability/peer review/etc. Thanks.
Option A:
-(IBAction)foo:(id)sender;
Option B:
-(IBAction)foo;
Upvotes: 5
Views: 667
Reputation: 11174
I always add the sender, mainly for consistency. Also because I generally don't use IB it makes it obvious which methods are action methods
Upvotes: 1
Reputation:
It's good practice to include the sender parameter, even if you don't need it. One reason: docs say you must conform to this and that parameter list. Another reason: if you'll need it later, it's good to have it.
Upvotes: 1
Reputation: 17081
I generally leave the "sender" in there. You might not need the sender now, but it is fairly common and might need it later, so instead of having to go back and add it back in, it is easy enough to just always leave it in (it autocompletes that way anyway). It definitely doesn't hurt anything.
Upvotes: 2