Was just doing a code review and started to wonder:
I thought if (self = [super init])
checks whether assigning return value of [super init]
They both do the same thing. The thing that the if
evaluates is the value of the expression inside it, which is the assigned value in an assignment. So when self
is not nil, you proceed into the if
block.
The second form throws parens around it to silence any potential compiler warnings about assignments inside conditionals, which is generally bad practice and possibly a typo. But this is idiomatic Objective-C, so it's fine to do it the first way.