• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Header import nightmare
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Header import nightmare (From: Bas Scheffers <email@hidden>)

  • Prev by Date: Header import nightmare
  • Next by Date: Re: Header import nightmare
  • Previous by thread: Header import nightmare
  • Next by thread: Re: Header import nightmare
  • Index(es):
    • Date
    • Thread