Was just doing a code review and started to wonder:
I thought if (self = [super init])
checks whether assigning return value of [super init]
to variable self
was successful or not (value of operation). Thus (self = nil)
would actually be TRUE
.
I thought if ((self = [super init]))
checks what is the value of self
after assignment (value of variable). Thus ((self = nil))
would be FALSE
.
Which one is the correct way to use when initialising your own classes? Apple documentation uses the former one (for example here), which style I'm actually using now.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…