0
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {  
        let alert = SCLAlertView()  
        alert.addButton("A",target:self,selector: #selector(FirstViewController.firstButton))  
        alert.addButton("B",target:self,selector: #selector(FirstViewController.secondButton))  
        self.dismiss(animated: true, completion: {  
            alert.showSuccess(kSuccessTitle,subTitle: kSubtitle1)  
//            self.present(secondViewController,animated: true,completion: nil)  
        })  
    }  
    @objc func firstButton(info: [UIImagePickerController.InfoKey : Any])  
    {  
        let sb = UIStoryboard(name:"Main",bundle: Bundle.main)  
        let secondViewController = sb.instantiateViewController(withIdentifier: "view2") as! SecondViewController  
        secondViewController.infoFromViewOne = info[UIImagePickerController.InfoKey.editedImage] as? UIImage  
        secondViewController.flag = 0  
        self.present(secondViewController,animated: true,completion: nil)  
    }  
    @objc func secondButton()  
    {  
        let sb = UIStoryboard(name:"Main",bundle: Bundle.main)  
        let thirdViewcontroller = sb.instantiateViewController(withIdentifier: "SecondViewController") as! ViewController  
        self.present(thirdViewcontroller,animated: true,completion: nil)  
    }  

This is my code, My desire result is that when I click the first button, the page jump to "SecondViewcontroller" and the image in the SecondViewcontroller's imageView is the photo I just select.

But now, after selecting the photo and click the first button, the app crashes at AppDelegate.swift, with an error message: "libc++abi.dylib: terminating with uncaught exception of type NSException"

What should I do to make it correct?

AtulParmar
  • 4,358
  • 1
  • 24
  • 45
Qizijia
  • 31
  • 6

1 Answers1

-2
private var infoFromViewOne: UIImage()
    var _infoFromViewOne:UIImage {
    set{ 
         _infoFromViewOne = newValue 
    }
    get{ 
         return _infoFromViewOne
    }
}

replace it with this remove error if because I don't have that exact code snippet right now but maybe can provide you tomorrow.

AtulParmar
  • 4,358
  • 1
  • 24
  • 45
Zeeshan Ahmed
  • 834
  • 8
  • 13
  • 1
    Answers are more helpful if they *explain* the problem and the solution. – Martin R Apr 10 '19 at 13:07
  • I added these code and there are something wrong:1.Invalid redeclaration of 'infoFromViewOne' 2.Attempting to modify '_infoFromViewOne' within its own setter 3.Attempting to access '_infoFromViewOne' within its own getter – Qizijia Apr 10 '19 at 13:12