You can show UIAlertControllers in SKScenes, simply show them on the rootViewController, which is probably the best place to show them anyway.
self.view?.window?.rootViewController?.present...
I dont like referencing the GameViewController in SKScenes and I never actually got to a point where I was forced to do so. NSNotificationCenter, delegation or protocol extensions are the better way.
I actually use a helper for Alerts I made using Swift 2's protocol extensions because I like clean, reusable and as little duplicate code as possible.
Just make a new .swift file and add this code
import SpriteKit
protocol Alerts { }
extension Alerts where Self: SKScene {
func showAlert(title title: String, message: String) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
let okAction = UIAlertAction(title: "OK", style: .Cancel) { _ in }
alertController.addAction(okAction)
self.view?.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
}
func showAlertWithSettings(title title: String, message: String) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
let okAction = UIAlertAction(title: "OK", style: .Cancel) { _ in }
alertController.addAction(okAction)
let settingsAction = UIAlertAction(title: "Settings", style: .Default) { _ in
if let url = NSURL(string: UIApplicationOpenSettingsURLString) {
UIApplication.sharedApplication().openURL(url)
}
}
alertController.addAction(settingsAction)
self.view?.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
}
}
Now in your scenes you need to show alerts you simply conform to the protocol
class GameScene: SKScene, Alerts {
}
and call the methods like
showAlert(title: "Alert title", message: "Alert message")
as if they are part of the scene itself.
Enjoy