Retrieving UIImage from UIImageView in Swift

Viewed 7107

I've found the solution but it is not in Swift: Converting UIImageView to UIImage

I've even went rogue by trying to implement it in Swift by using UnsafeMutablePointed and had no luck.

However, pointers are typically frowned upon in Swift and it would be nice if there was a simple one-liner solution to this!

Example Code:

let test1:UIImageView = UIImageView(image: UIImage(named: "test")) 
let test2 = test1.image // This fails with an error: Instance member ‘test1’ cannot be used on type ‘viewController’
2 Answers
Related