Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CADisplayLink forward declaration error

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!

like image 711
Chad Avatar asked Aug 12 '11 18:08

Chad


1 Answers

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.

like image 171
jtbandes Avatar answered Sep 25 '22 12:09

jtbandes