I get the error :
Subject 1: EXC_BAD_INSTRUCTION (code = EXC_1386_INVOP, subcode = 0x0)
when trying to transfer an image selected from the photo library to another view controller.
Source ViewController -
@IBAction func myButtonTapped(_ sender: UIButton)
{
let secondVC = storyboard?.instantiateViewController(withIdentifier: "secondVC") as! secondVC
secondVC.passedVName = VNameTextField.text!
secondVC.passedCcName = DropTextBox.text!
secondVC.passedVImage = VImageView.image!
navigationController?.pushViewController(secondVC, animated: true)
}
The purpose of the ViewController is
class secondVC: UIViewController
{
@IBOutlet weak var DisplayPassedImage: UIImageView!
@IBOutlet weak var ccNameDisplayLabel: UILabel!
@IBOutlet weak var VNameDisplayLabel: UILabel!
var passedVName = ""
var passedCcName = ""
var passedVImage = UIImage()
override func viewDidLoad()
{
super.viewDidLoad()
VNameDisplayLabel.text = passedVName
ccNameDisplayLabel.text = passedCcName
DisplayPassedImage.image = passedVImage
}
}
Note. . PassedVName and 'passCcName' data are successfully passed to the target ViewController. if I try to pass 'passVImage', I get an error message.
source
share