Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Game with Sprite Kit Physics and Collision Adding Enemies

I am getting an error: ARC semantic issue: NO known class method for selector 'spriteNodeWithImageNamed:'

My header file looks like this:

import <SpriteKit/SpriteKit.h>

typedef NS_ENUM(NSUInteger, THSpaceDogType) { THSpaceDogTypeA = 0, THSpaceDogTypeB = 1 };

@interface THSpaceDogNode : SKNode

  • (instancetype) spaceDogOfType: (THSpaceDogType)type;

@end

and my implementation file looks like this:

import "THSpaceDogNode.h"

@implementation THSpaceDogNode

  • (instancetype) spaceDogOfType: (THSpaceDogType)type { THSpaceDogNode *spaceDog;

    if (type == THSpaceDogTypeA) { spaceDog = [self spriteNodeWithImageNamed: @"spacedog_A_1"]; } else { spaceDog = [self spriteNodeWithImageNamed: @"spacedog_B_1"];

    }

    return spaceDog; }

@end

However I get an error inside the if statement where the two lines make the sprite for the space dog enemies. it says, "No known class for method for selector 'spriteNodeWithImageNamed:'

That error is repeated twice. I have no idea what I did wrong, I went so far as to even delete the code, and start from the beginning of the video and it still says the same thing. Am I doing something wrong here?

JUST KIDDING. I found out my problem, when I created the new class, I didn't create it as a subclass of SKSpriteNode. It works now. (:

1 Answer

How could you become a programmer without not doing that much:) Good luck.