Q&A: How To Fix Xcode’s "used as the name of the previous parameter" warning

When you upgrade to Xcode 4.6, you may find that you are getting a number of compiler warnings like this:

‘xxxxx’ used as the name of the previous parameter rather than as part of the selector

In this post I will show you why you’re getting this warning, how to fix it, or how to ignore it.

Why You’re Getting This Warning

This is typically caused by declaring a method without specifying a description of the parameter. For example, check out the following method declaration:

– (NSString *) getFormattedDateString:(NSDate *)date:(NSString *)formatString;

The intent of this code is to declare a method named getFormattedDateString that accepts two parameters named date and formatString.

Because there is no space between date and the colon (:), the compiler gives the warning “‘date’ used as the name of the previous parameter rather than as part of the selector”.

How to Fix The Problem

There are two ways to solve this warning:

1. Put a space between date and the colon:

– (NSString *) getFormattedDateString:(NSDate *)date :(NSString *)formatString;

2. Add a description for the formatString parameter:

– (NSString *) getFormattedDateString:(NSDate *)date withFormat:(NSString *)formatString;

The second option is preferable because it makes your method more readable. That;s because parameter descriptions are part of the method signature. In this example, the method signature is:


If you leave out the parameter description, the method signature is the less readable:


How to Ignore the Warning

Although it’s preferable to fix these warnings by changing your method declarations, if you want to ignore them, you can simply add the following declaration to your project’s PCH file (located in the Support Files group):

#pragma clang diagnostic ignored “-Wmissing-selector-name”

All the best!

Kevin McNeish


Author: iOS App Development for Non-Programmers book series
Twitter: @kjmcneish

Leave a Reply

Your email address will not be published. Required fields are marked *