Historically I've successfully used the == comparator when comparing an image in an imageView to some predefined image using [UIImage imageNamed:]. This is because I receive the same object when calling [UIImage imageNamed:] repeatedly with the same filename, such as:
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a1433a0>
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a1433a0>
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a1433a0>
Using Xcode 6 Beta 4, a number of my unit tests are failing when trying to compare an image in an imageView to an expected image, and it seems that is because I am given a unique instance of the image with a given filename each time, rather than the old behavior explained above. When doing the same thing in Xcode 6 Beta 4, I get this:
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a691f00>
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a6a1d00>
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a1f3230>
(lldb) po [UIImage imageNamed:@"foo.png"]
<UIImage: 0x7a6a1fd0>
Is this expected behavior, something I'm missing in the documentation for UIImage, perhaps an implementation issue I should address differently, or is this something I should file with Apple as a bug? Any insights?
I just tried the same thing in iOS 7 and I had the expected output (i.e same object for all vars) But when I run the same thing in iOS 8 I get different objects. (Both times using Xcode 6 beta 4)
So I checked the docs for iOS 7 we have:
iOS 8:
There is nothing in the seconde text that specifies exactly that this call caches the data, so maybe it's attended (Which doesn't make any sense) or it's a bug. My advice is to send a bug report, and see what they'll say.
Ayu.