• 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 Wellington <email@hidden>
  • Date: Sun, 17 Jun 2007 13:43:35 +1000


On 17/06/2007, at 1:27 PM, 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"

And all is well.

The problem comes from then trying to create this method in PGConnection:
-(PGPreparedStatement *) prepareStatement: (NSString *) sql nParams: (int) nParams;


To make it compile, I also add (to PGConnection.h)

#import "PGPreparedStatement.h"

Only import a header when you need the actual declaration of the class (with methods and the like). If you just need to say that this is a class, simply declare it as such with @class.


A nice simple example usage is shown below:

------ ClassA.h ------
#import <Foundation/Foundation.h>
@class ClassB;
@interface ClassA : NSObject {
	ClassB *myB;
}
- (ClassB *)myB;
- (void)setMyB:(ClassB *)myB;
--------------------------

Note that even though we use ClassB in this header, we don't need to import ClassB.h. You should import ClassB.h in the implementation of ClassA, that is in ClassA.m. You should however import the declaration for the superclass.

A more detailed explanation is here: http://www.cocoadev.com/index.pl? AdviceOnImportingHeaders

Andrew
_______________________________________________

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: Re: Header import nightmare
  • Next by Date: Re: Resolution-independent toolbar icons
  • Previous by thread: Re: Header import nightmare
  • Next by thread: Get list of installed applications in the Mac
  • Index(es):
    • Date
    • Thread