I am trying to compare two UIImages. If I compare it like this:
if ([UIImagePNGRepresentation ( holderImage) isEqualToData:UIImagePNGRepresentation([UIImage imageNamed:@"empty_image.png"])])
NSLog(@"empty image");
else
NSLog(@"not empty image");
As a result of YES, THEY ARE EQUAL
if i do the following
` if ([holderImage isEqual:[UIImage imageNamed:@"empty_image.png"]])
NSLog(@"empty image");
else
NSLog(@"not empty image"); `
no result, they are NOT
The situation is rather complicated because:
1) Images SHOULD BE (this means I'm pretty sure) equal, so I would believe the first if
2) isEqual comparison always gives true results in other images.
So, I'm completely confused. what do you think about it? Btw the ownerImage was just taken from NSUserDefaults. Do you think this can be changed in some way when stored in NSUserDefaults, so now isEqual compares?
source
share