I code therefore I am.

August 19, 2011 at 12:49pm
0 notes
Comments (View)
home

Tags:
Objective-C  

Setting to nil

NSObject *obj;
if (obj != nil) {
    //code will enter here and we'll get a bad access error to obj!
}
vs.
NSObject *obj = nil;
if (obj != nil) {
    //obj is nil so we're safe if we do something with obj
}

blog comments powered by Disqus