Hi there, I do not understand how data are passed to a func with parameters when it is used as selector sign.
Example:
if I'd like to add an argument "okMessage: String" to be printed on saving
then adding at the very end of the func something like "print(okMessage)" (no matter usage, just for sake of understanding),
then pass "hello, all done here" , how could pass that string?
the code from the lesson
@IBAction func save(_ sender: Any) {
guard let image = imageView.image else { return }
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(_:didFinishSavingError:contentIinfo:)), nil)
}
@objc func image(_ image: UIImage, didFinishSavingError error: Error?, contentIinfo: UnsafeRawPointer) {
if let error = error {
let ac = UIAlertController(title: "Save error", message: error.localizedDescription, preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
present(ac, animated: true, completion: nil)
} else {
let ac = UIAlertController(title: "Saved!r", message: "modified image saved", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
present(ac, animated: true, completion: nil)
}
}