Re: Header import nightmare
Re: Header import nightmare
- Subject: Re: Header import nightmare
- From: Andrew Farmer <email@hidden>
- Date: Sat, 16 Jun 2007 20:40:05 -0700
On 16 Jun 07, at 20:27, Bas Scheffers wrote:
I have two classes (well, I have more, but to simplify the problem
I focus on these two):
- PGConnection
- PGPreparedStatement
PGPrepared statement has methods that take PGConnection as argument
and this in PGPreparedStatement.h I do:
#import "PGConnection.h"
...
Stop right there.
Don't #import class headers from other class headers. As you've
learned, that causes problems when you invariably end up creating a
circular import. Instead, when you need to refer to another class in
a class header, write:
@class AnotherClass;
near the top of the file to create a forward declaration of the class
(similar to a function prototype), then #import all the relevant
headers in the source files.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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