Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
Hi all,
i want to know how to compare the content of two objects.isEqualTo compares the reference.I tryed using isEqualTo,even though the values of properties are same it is returning no.
 

CommanderData

macrumors 6502
Dec 1, 2007
250
3
Hi all,
i want to know how to compare the content of two objects.isEqualTo compares the reference.I tryed using isEqualTo,even though the values of properties are same it is returning no.

What do the objects contain? Can you be more specific? NSStrings? Custom Classes?
 

SqueegyX

macrumors regular
Mar 24, 2008
108
1
If its your own class, implement your own isEqual: method. Test if its the same class, then compare its values.

By befault, 2 NSSobjects are only the same if they are the same objects. Meaning if you instantiate 2 object with the same values, they will be be "Equal". Classes like NSString override the isEqual: method in order change what is considered "Equal".
 

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
Thanks.Ya it's my own class,two objects which i am comparing are of same type and thay have the same contents also,but the refrences are diffrent.So in this scenario do i still need to implement my own isEqual method?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.