ios - Why would you want to cast [NSNull null] -


i don't understand if statement doing. why cast [nsnull null] way ?

caanimation *action = (caanimation *)[self actionforlayer:layer forkey:@"backgroundcolor"];     if (action != (caanimation *)[nsnull null])     {         //stuff     } 

found on gist feel noob!

from blog read, can read this

in code below, create uilabel subclass called fancylabel, , override actionforlayer:forkey: returns [catransition animation] contents key instead of [nsnull null] (which method returns normally):

so,this method can return [nsnull null].

then test code

    caanimation *action = (caanimation *)[nsnull null]; if (action == (caanimation *)[nsnull null]) {     nslog(@"same address"); } 

this log same address

so if try delete cast

   caanimation *action = (caanimation *)[nsnull null]; if (action == [nsnull null]) {     nslog(@"same address"); } 

it still log same address,but gives warning

so,since [nsnull null] singleton, if 2 pointer point ,it must ==.

therefore,here suppress warning


Comments