UIImageView - How to get the file name of the image assigned?

Kuberchaun picture Kuberchaun · Nov 16, 2009 · Viewed 127.2k times · Source

Is it possible to read the name of an UIImageView's UIImage that's presently stored in the UIImageView?

I was hoping you could do something kind of like this, but haven't figured it out.

NSString *currentImageName = [MyIImageView getFileName];

Answer

Nizar Ahmed picture Nizar Ahmed · Sep 4, 2012

you can use setAccessibilityIdentifier method for any subclass of UIView

UIImageView *image ;
[image setAccessibilityIdentifier:@"file name"] ;

NSString *file_name = [image accessibilityIdentifier] ;