lundi 29 juin 2015

Swift segue fatal error

ViewController

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if (segue.identifier == "Segue") {
        var svc = segue.destinationViewController as! ViewController2;

        svc.vericik = self.vericik

    }
}


@IBAction func gotoView2(sender: AnyObject) {
    self.performSegueWithIdentifier("Segue", sender: self)
    self.presentViewController(ViewController2(), animated: true, completion: nil)
}

ViewController2

var vericik: String!

    @IBOutlet weak var VeriYeri: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        VeriYeri.text = vericik
    }

When I click button on ViewController, ViewController2 page comes to screen and I can see segue data which come from ViewController. But after that, an error occurs: fatal error: unexpectedly found nil while unwrapping an Optional value

Where am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire