• 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: Where/when to #import
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where/when to #import


  • Subject: Re: Where/when to #import
  • From: tiennou <email@hidden>
  • Date: Tue, 9 Oct 2007 16:15:24 +0200

Le 9 oct. 07 à 15:41, Nelson Santos a écrit :

Hi Paul,

Here are the rules that I follow which seems to work very well for me:

(1) #import <Cocoa/Cocoa.h goes in your class's .h file.
(2) Use @class only in your .h files for all of your class references used (unless you derived your class from another class, in which you need to use the #import directive, because the compiler needs to know everything about the original class when you derive.)
(3) Place all other #import directives in your .m files.

I'm using this too, because I was stung with a cross-reference one time and discovered I was doing wrong (I was #import'ing everything in *.h files)... Another little addition, if you're building a framework :
It's better to use #import <framework/file.h> syntax in your public API headers, so that someone including your framework don't need to add an unnecessary include path to their project... (I had problem with this in the past, but I can't remember how...)


Etienne Samson_______________________________________________

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


References: 
 >Where/when to #import (From: Paul Bruneau <email@hidden>)
 >Re: Where/when to #import (From: Nelson Santos <email@hidden>)

  • Prev by Date: Re: Binding NSMenuItem 'value' or 'title': Accessors not invoked
  • Next by Date: Re: Custom compare: for NSDate sort descriptor
  • Previous by thread: Re: Where/when to #import
  • Next by thread: Re: Where/when to #import
  • Index(es):
    • Date
    • Thread