If you're using [UIImage imagedNamed:]
, the images are cached. Excerpt from the UIImage class reference for imagedNamed:
:
This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.
This means you can assert on cell.imageView.image == [UIImage imagedName:@"my_image"]
as this is a pointer comparison and since the images are cached multiple calls to imageNamed:
with the same name will return the same pointer. Even if memory gets tight, you should still be fine, as the UIImage class reference explains:
In low-memory situations, image data may be purged from a UIImage object to free up memory on the system. This purging behavior affects only the image data stored internally by the UIImage object and not the object itself.