0

In objective-C, to move another viewcontroller from different storyboard, we will use following coding to fulfil what we want.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Customer" bundle:nil];
HomeSummaryViewController *creaccVC = [storyboard instantiateViewControllerWithIdentifier:@"HomeSummaryViewController"];
[self.navigationController pushViewController:creaccVC animated:YES];

In swift version, please help me to how to do just like Objective-C?

PPShein
  • 13,309
  • 42
  • 142
  • 227

2 Answers2

5

It's pretty much identical to the Objective-C version.

    let storyboard = UIStoryboard(name: "Customer", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("HomeSummaryViewController")
    self.navigationController?.pushViewController(vc, animated: true)
Adam
  • 26,549
  • 8
  • 62
  • 79
  • '_??' is not convertible to 'Void' – PPShein Sep 24 '15 at 08:28
  • The code worked fine for me. Are you using Xcode 7 and Swift 2? Or perhaps there is an error somewhere else in your code. – Adam Sep 24 '15 at 08:35
  • The code i posted is written in Swift 2. You should consider upgrading to Xcode 7 and converting your project to Swift 2. – Adam Sep 24 '15 at 08:38
0

The above code in Swift looks like this:

    let storyboard: UIStoryboard = UIStoryboard(name: "Customer", bundle: nil)
    let homeView: HomeSummaryViewController = storyboard.instantiateViewControllerWithIdentifier("HomeSummaryViewController") as! HomeSummaryViewController 
    self.navigationController?.pushViewController(homeView, animated: true)
Dejan Skledar
  • 11,280
  • 7
  • 44
  • 70