I have a UIImageView that holds a cover photo for a user. Through the xcode IDE I added a placeholder image that acts as a stock cover photo. When the user clicks on the cover photo I need a way to tell if the image inside the UIImageView is the stock cover photo or another photo that the user has added. The image is never nil. Currently I am doing it by comparing the image data of the current cover photo to the image data generated buy creating an image from the stock cover photo image file.
This is what I have:
if ([UIImagePNGRepresentation(_coverPhoto.image) isEqualToData:UIImagePNGRepresentation([UIImage imageNamed:@"stockCoverPhoto.png"])])
{
[self loadPhoto:1];
}
Comparing the _coverPhoto.image to UIImage imageNamed:@"stockCoverPhoto.png" produced buggy results when the app was closed and reopened within the same session. There must be a better way to do this, I need my code to be as efficient as possible and comparing two NSData structures to one another seems unnecessary.