Swift 3, Xcode 8, IOS:
I can't seem to figure out what I'm doing wrong, no errors show up, but when I click the button in my app, nothing happens and nothing is saved in my simulators camera roll.
This is what I've done for the button in the view controller:
import UIKit
class ViewController: ViewController {
override func viewDidLoad() { 
    super.viewDidLoad() 
}
override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
}
@IBAction func buttonAction(_ sender: UIButton) {
    func captureScreen() {
        UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale)
        view.layer.render(in: UIGraphicsGetCurrentContext()!)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)
    }
}
}
