0
votes

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?

1
- (IBAction)goBack:(id)sender { [self dismissViewControllerAnimated:YES completion:nil]; } - Watsche
doesn't seem to work correctly too - junyi00

1 Answers

1
votes

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.