Sending ‘const NSString *’ to parameter of type ‘NSString *’ discards qualifiers [Solved]

For example, write const NSString* firstString = @"xxx";
NSString* secondString = @"yyyy";
[secondString isEqualToString:firstString];
There is a warning about sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers.
Workaround.
Change const NSString* firstString = @"xxx";
to NSString* const firstString = @"xxx";

Explanation: The former is equivalent to the pointer itself is not modifiable, the latter indicates that the content pointed to by the pointer is not modifiable, both serve to make firstString readable and unwritable only.

 

Read More: