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
toNO
.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.