ViewController with Skview - SpriteKit SKScene
<p>first try and bit stuck on this one...</p>
<p>I Have a ViewController that I wish to display an SKScene in its view
I've tried everything I can think of but its not showing</p>
<hr />
<ul>
<li>add SpriteKit/SpriteKit.h</li>
<li>Main.storyboard has a single view controller (myViewController).</li>
<li>myViewController's view - change class to be SKView. (see pic below)</li>
<li>Viewdidload</li>
<li>link to SKScene I wish to load (HelloScene) #import &quot;HelloScene.h&quot;</li>
</ul>
<hr />
<pre><code>//ViewController.m
#import &quot;myViewController.h&quot;
#import &lt;SpriteKit/SpriteKit.h&gt;
#import &quot;HelloScene.h&quot;
@interface myViewController ()

@end

@implementation myViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    SKView *spriteView = (SKView *) self.view;
    spriteView.showsDrawCount = YES;
    spriteView.showsNodeCount = YES;
    spriteView.showsFPS = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
</code></pre>
<hr />
<p>HelloScene.h</p>
<pre><code> #import &lt;SpriteKit/SpriteKit.h&gt;
  @interface HelloScene : SKScene 
  @end
</code></pre>
<hr />
<p>HelloScene.m</p>
<pre><code>#import &quot;HelloScene.h&quot;

@interface HelloScene ()
@property BOOL contentCreated;
@end

@implementation HelloScene

- (void)didMoveToView: (SKView *) view
{
        [self LoadSceneContents];
}

- (void)LoadSceneContents
{
    self.backgroundColor = [SKColor blueColor];
    self.scaleMode = SKSceneScaleModeAspectFit;
    [self addChild: [self newHelloNode]];
}

- (SKLabelNode *)newHelloNode
{
    SKLabelNode *helloNode = [SKLabelNode labelNodeWithFontNamed:@&quot;Chalkduster&quot;];
    helloNode.text = @&quot;Hello, World!&quot;;
    helloNode.fontSize = 42;
    helloNode.position = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame));
    return helloNode;
}

@end
</code></pre>
<hr />
<p><a href="https://i.stack.imgur.com/KBj3T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KBj3T.png" alt="enter image description here" /></a></p>
<p>Above:Selecting the view controller’s view object and change its class to SKView</p>