Re: Can't create pointer to custom class
Re: Can't create pointer to custom class
- Subject: Re: Can't create pointer to custom class
- From: Graham Cox <email@hidden>
- Date: Thu, 21 Aug 2008 14:32:10 +1000
On 21 Aug 2008, at 8:37 am, Nathan wrote:
I created a class, and want to make a pointer to it in another
class. So I did,
ESAnimation *animation;
ESAnimation turns green when I write it so I know it's recognizing
it, though I would expect it to turn blue. But when I try
compiling, it says syntax error before 'ESAnimation'. So I took out
the line of code, which was the only line of code I had written so
far in that class, and everything compiled fine. What's wrong? Also
on the same subject, I originally had the class in a framework,
which I put properly and completely into my project. It's sitting
right in front of me. But the same line of code stayed all white.
It wouldn't recognize the class name. Any help is appreciated.
Thanks, Nate
I assume you have something like this:
//SomeClass.h
@interface SomeClass : NSObject
{
ESAnimation* animation;
}
@end
That won't compile because ESAnimation isn't known at this point.
There are two ways to solve it. You can either import the
ESAnimation.h header here, or better, add a forward declaration:
@class ESAnimation;
Note - relying on syntax colouring is not ideal. Syntax colouring is
based on searches and some very basic parsing of the file, not on a
complete compilation of the code. So what it can 'see' is not
necessarily indicative of the correctness of the code or whether it
will compile. Also, terms like 'it turned blue' or 'it turned green'
really don't mean anything - many of us use different settings or
different editors.
hth,
Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden