0
votes

I show UIAlertController() using NSNotificationCenter from the SKScene.

Then when one of the options is clicked to execute method in SKScene(). The method will add a node, but if I use

let s = GameScene()
s.methodName()

This doesnt use the current reference, but creat a new scene and the node is not added

If I pass the Scene when sending the notification like so

NSNotificationCenter.defaultCenter().postNotificationName("detectNot", object: self);

After given option is chosen and the method is execute it gives an error, there is no info about the error

1

1 Answers

1
votes

Send the notification like this

NSNotificationCenter.defaultCenter().postNotificationName("detectNot", object: self);

In the UIViewController method

let _scene = notification.object as! GameScene

Then you can access any method