5

Okay, so I've been completely stumped by this compiler error for hours, and the problem is that all the googling I've done says it should work the way I have it! I'm following a book tutorial for iPhone game development, and I got stuck on the second chapter because of a random compiler error.

NOTICE: I am currently running and testing in XCode 4.1 with iOS 5 beta

Here's the declaration:

In header file:

@interface GameController : NSObject
{
    CADisplayLink *displayLink;
}

@end

In the .m file

- (void)startGame {
    displayLink = [displayLinkWithTarget:self selector:@selector(update:)];  // THROWS ERROR
    [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];  // THROWS ERROR
}

- (void)update:(CADisplayLink *)sender {
    // TODO: actually do something..
}

Both of these throw the error: Receiver 'CADisplayLink' for class message is a forward declaration

But all the posts online have the line exactly the same. The error type is a 'Automatic Reference Counting Issue'.

Any help is greatly appreciated!

Abizern
  • 146,289
  • 39
  • 203
  • 257
Chad
  • 275
  • 3
  • 13

2 Answers2

12

You need to #import <QuartzCore/QuartzCore.h> at the top of your source file, and link the QuartzCore framework if you haven't already done that.

jtbandes
  • 115,675
  • 35
  • 233
  • 266
3

Have you added the QuartzCore framework to your project and the related import to this class?

CADisplayLink comes from that framework.

Abizern
  • 146,289
  • 39
  • 203
  • 257