Equal Analysis Objective-C language pointer to an object in equality.

Objective-C what language when comparing two objects, must be considered "equal" means that need to distinguish between pointers and equal equality, equal pointer easily. If now two objects point to the same memory location, then the object is equal to the net. Here equality is not difficult to understand, is that two different objects, but their contents are equal. (Eg: NSString * str1 = @ "wgw8299 " and NSString * str2 = @ "wgw8299" ), their pointers are not equal in this case. Because it is a different subject, they are certainly not the same as a memory address. Substantially equal to the pointer can be directly used for comparison relational operators, equality is not then must write a class method to do the comparison target content.

Reproduced in: https: //my.oschina.net/tiwer/blog/199846

Guess you like

Origin blog.csdn.net/weixin_33757609/article/details/91708528