As to how to access the ViewController (and its properties) from your SKScene or any SKNode, I would save a pointer inside those SKNodes after creation.
@interface YourScene : SKScene
@property (weak,nonatomic) UIViewController * presentingViewController;
@end
// inside the ViewController
YourScene * scene = [YourScene new];
scene.presentingViewController = self;
[skView presentScene:scene];
An answer to your title question: Displaying alertViews in SpriteKit
You don't have to put the alertView
property in your ViewController; you can just put it in your SKScene, or wherever you like. You don't even have to set a delegate, but if you want to just have your SKScene subclass conform to the UIAlertViewDelegate
protocol.
@interface YourNode : SKNode<UIAlertViewDelegate>
- (void) displayAlert;
@end
// ...
@implementation YourNode
- (void) displayAlert {
UIAlertView * alertView = [UIAlertView alloc] initWithTitle:@"Your title" message:@"Your message is this message" delegate:self cancelButtonTitle:@"Cancel me" otherButtonTitles:@"Whatever", nil];
[alertView show];
}
@end