When I use this code:
NSString *a = nil;
NSString *b = nil;
if([a isEqual:b]){
NSLog(@"YES");
}
else{
NSLog(@"NO");
}
The console print “NO” I don’t understand this behavior. Could you explain me ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The rules for sending messages to
nilare as follows:(Source: https://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-SW7)
sizeof(void*), afloat, adouble, along double, or along long, then a message sent tonilreturns0.struct, as defined by the Mac OS X ABI Function Call Guide to be returned in registers, then a message sent tonilreturns0.0for every field in thestruct. Otherstructdata types will not be filled with zeros.nilis undefined.(Thanks @Jim)
So for example, if you do this:
It will print out “Watch this” every time.