objective c - Need an iPhone Programmer judge every step and every pointer == nil? -


for example:

nsstring *mystring = [[nsstring alloc] init]; if (nil == mystring) {     return; } 

need this??thank you!

no, don't need that, , can't i've ever seen code made pervasive use of pattern.

also, if statement can shortened to:

if (! mystring) {     return; } 

...which equivalent though no less superfluous. checking nil can useful, typically not done after object instantiation. instead typical case ensure object not over-released, instance using pattern like:

if (myobj) {     [myobj release];     myobj = nil; } 

note calling method on nil allowed in objective-c, less harm caused unexpected nil value floating around in languages java attempting null reference throws exception.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -