ios - Navigation Between Two View Controller -


i have 2 view controllers. in mainviewcontroller there tabbarbutton when clicked user goes 1stviewcontroller , there uibutton when has clicked user goes 2ndviewcontroller.

before making 2ndviewcontroller worked fine. after add segue function in program got error.

could not cast value of type 'calculator.1stviewcontroller' (0x791a8) 'calculator.2ndviewcontroller' (0x794c8).

briefly code is

  @ibaction func calculategpa(){ //calucation goes here }  override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {         var anothername : 2ndviewcontroller = segue.destinationviewcontroller as! 2ndviewcontroller //code here } 

uibutton perform segue , barbutton nothing go 1stview controller. when run program , click barbutton im getting above error.

its because prepareforsegue cant identify button should perform right? how solve it?

try code.

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject!) {     if (segue.identifier == "youridentifiername") {       //your class name         if let viewcontroller: deallandingviewcontroller = segue.destinationviewcontroller as? deallandingviewcontroller {             viewcontroller.dealentry = deal         }      } } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -