I have recently (e.g. just now) upgraded to XCode 4, and I like it overall, however, there is one thing that annoys me.
When I write code like this:
if (self = [super init])
{
...
}
It gives me an 'issue': Using the result of an assignment as a condition without parentheses
How can I suppress this warning, as It underlines all the text in red, making me think that there is a critical error. As I am a somewhat seasoned Objective-C coder, I really don't want to change my practices and add extra parentheses around my init statements.
You can either put an additional set of parentheses in the if statement
if ((self = [super init])) {
...
}
Or, you can do as the new templates do.
self = [super init];
if(self) {
...
}
I found the answer to this question here: if(self = [super init]) - LLVM warning! How are you dealing with it?
Which prescribes adding the "-Wno-idiomatic-parentheses" flag in the building settings. Which did the trick for me.
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