XCode 4 if (self = [super init]) issue

前端 未结 8 1005
野的像风
野的像风 2021-01-02 17:36

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:

         


        
相关标签:
8条回答
  • 2021-01-02 17:59

    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) {
        ...
    }
    
    0 讨论(0)
  • 2021-01-02 18:00

    Double parenthesize it.

    if ((self = [super init]))

    It's just making sure you really know what you're doing.

    I'm unsure if there is any way to silence the actual warning in XC4, as it isn't a compiler warning.

    0 讨论(0)
提交回复
热议问题