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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With