I've opened up some old iOS code and when I try to build it I get an "unused parameter" error for code like this:
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
NSLog(@"Search Bar isn't used in this function");
}
This is the first time I've ever seen an Objective-C compiler spit out errors (not warnings) for this. Since a lot of iOS calls don't necessarily use the passing arguments (examples being a lot of callbacks), I need help in getting rid of this.
Solution # 1)
In your Xcode project's "Build Settings", there's a parameter for "Unused Parameters".
Reset that from YES
to NO
.
Solution # 2 (available with Xcode 4):
In Xcode 4.3.2 or higher use __unused
.
(THANKS to Tim Bodeit's comment below)
Solution # 3)
Put #pragma unused (searchBar)
in your code, preferably right underneath the line in your implementation where the function is declared.
I.E.
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
#pragma unused (searchBar)
NSLog(@"Search Bar isn't used in this function");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With