Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C: if (object) Vs. if (object != nil)

Assuming object is a kind of NSObject, the following if statements are equivalent, but which style should I use?

if (object) {
    // ...
}

or

if (object != nil) {
    // ...
}
like image 911
ma11hew28 Avatar asked Jun 16 '11 02:06

ma11hew28


1 Answers

As you say, they're equivalent. Thus...

which style should I use?

Whichever one you want.

like image 173
Dave DeLong Avatar answered Oct 17 '22 07:10

Dave DeLong