开发者

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 followin开发者_Python百科g 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!


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.


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

CADisplayLink comes from that framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜