ios - How to run a segue on itself OR another viewController -


i have main tableviewcontroller. when user tap on cell in tableview, if condition statement true, show main tableviewcontroller again(but show data on screen), , if condition false, show viewcontroller. in prepareforsegue method have this:

if  segue.identifier == "identifier1" {     let destination = segue.destinationviewcontroller as? mainviewcontroller //     destination!.x = // x variable in view controller } else if segue.identifier == "identifier2" {     let destination = segue.destinationviewcontroller as? viewcontroller2     destination!.y = } 

also, run segue after tap on cells in tableview added this:

override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {     tableview.deselectrowatindexpath(indexpath, animated: true)      if condition true {         self.performseguewithidentifier("identifier1", sender: self)     }     else{         self.performseguewithidentifier("identifier2", sender: self)     } } 

storyboard segue needs identifier... can have 1 value! identifier1 or identifier2 want set identifier programmatically. how should set identifier in storyboard segue? there way this? thanks!

the destination view controller set segue. since have 2 different destinations, need 2 different segues in storyboard.

the trick wire segues viewcontroller icon @ top of tableviewcontroller each of destination view controllers. click on resulting segue arrows , set identifiers in attributes inspector.

wire segue in storyboard

then can call them performseguewithidentifier have done in code.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -