In my storyboard I have a few images that are "User Interaction Enabled".
In the UIViewController I override the touchesEnded function.
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
}
Is it possible for me to get the name of the image that was clicked in this function? I would prefer not to @IBOutlet the images.
I'm fairly certain this is not possible exactly like you want it. Image views don't retain the file they loaded the image from, just the image data itself. But I assume you're setting the image names in IB and trying to get that name after a touch event, in that case you could set the image name in the element's restoration ID and retrieve the name via the restorationIdentifier property of the touched element.
You can get the touched element like this:
Note that you have to set the image file name twice if you want to do it like this, and change the value twice when making changes. What you are trying smells of bad design, so if there's another way I'd go with that.