I have a list of Objects that I pull from a web service. When I update my UITableView, I retrieve the objects again from the web service, and compare them to each other for equality. I then remove the ones that are not present, and insert the new objects, then update my UITableView. How can I test to see if the new object equals the old object? I've created a test for clarity..
requestA should equal requestC, but fails.
Is this possible to do without looking at each property value as the objects have many values?
I was originally comparing the ID only, but this doesn't work as sometimes other property values change and the ID stays the same.
Request *requestA = [[Request alloc] init];
Request *requestB = [[Request alloc] init];
Request *requestC = [[Request alloc] init];
requestA.requestID = @"1";
requestA.productName = @"Clutch";
requestB.requestID = @"2";
requestB.productName = @"Wiper";
requestC.requestID = @"1";
requestC.productName = @"Clutch";
if (requestA == requestB)
NSLog(@"A == B");
if (requestA == requestC)
NSLog(@"A == C");
if ([requestA isEqual:requestB])
NSLog(@"A isEqual B");
if ([requestA isEqual:requestC])
NSLog(@"A isEqual C");
// Look at the pointers:
NSLog(@"%p", requestA);
NSLog(@"%p", requestB);
NSLog(@"%p", requestC);