johnbakers
johnbakers

Reputation: 24771

How to extract the file name of an UIImage?

I am trying to get the imageNamed portion of an UIImage. I had previously set the UIImage using imageNamed and created an array of UIImages, now I want to enumerate through the array and extract the filename from each, as a test. Is this possible? For example:

   for (id key in self.images){
        UIImage *test=key;
      //now do something with test to get its name, how?
    }

The reason I am doing this is because my array of animated images is not working and I want to verify that the contained images are in fact legitimately named.

Upvotes: 0

Views: 1469

Answers (1)

Eimantas
Eimantas

Reputation: 49354

You can't. Since UIImage instance can be created from few sources, the imageNamed: is just a shortcut (i.e. one of the ways to instantiate an image). Others are image creation from CGImage or just plain data bytes (NSData). You should create your own registry of created named images (something like dictionary with filename => UIImage key/value pairs).

Upvotes: 2

Related Questions