0

I'm trying to reach a settings screen from SKScene.

This is how I present the settings controller:

let storyboard = UIStoryboard(name: "Main", bundle: nil);
let settingController: UIViewController = storyboard.instantiateViewControllerWithIdentifier("Settings") as UIViewController

let vc = self.view.window.rootViewController;
vc.presentModalViewController(settingController, animated: true);

but once I run this code to dismiss:

@IBAction func backToGame(sender : AnyObject) {
    [self.parentViewController .dismissModalViewControllerAnimated(true)];
}

I get EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) error, with nothing shown in the log.

How do I solve this?

Confused
  • 6,048
  • 6
  • 34
  • 75
junyi00
  • 792
  • 3
  • 8
  • 28

1 Answers1

1

I was a fool not knowing I just got confused between objective-C and swift. It seems that the problem came from where I used obj-C instead of swift when my project is suppose to be compiled in swift.

@IBAction func backToGame(sender : AnyObject) {
    self.dismissModalViewControllerAnimated(true);
}

This solved my problem immediately.

Neeku
  • 3,646
  • 8
  • 33
  • 43
junyi00
  • 792
  • 3
  • 8
  • 28