• 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: Avoiding cyclic header imports
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding cyclic header imports


  • Subject: Re: Avoiding cyclic header imports
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 10 Jul 2012 17:16:25 -0700

On Jul 10, 2012, at 5:01 PM, Erik Stainsby <email@hidden> wrote:

> where -[RSRule loadFromPlugin:] copies the values to the rule. This requires however that RSRule #imports the RSPlugin header.
>
> I also would like to maintain symmetry by having RSPlugin import the values of RSRule, for purposes of round-tripping to the UI (plugin reps the UI for a rule instance).  Obviously, this would require RSPlugin to #import RSRule's header.  Xcode doesn't like this one bit.

You need to #import the other class's header in the .m file, but not in the .h file. There you can just declare it like "@class RSRule;". That should be enough to avoid circular #imports (and by the way, greatly reduce the number of #imports in your headers, which is good for reducing build times.)

About the only times you need to #import another header are if it declares the superclass of an @interface, or a protocol you're implementing, or some typedef or enum that's used in the API.

—Jens
_______________________________________________

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: 
 >Avoiding cyclic header imports (From: Erik Stainsby <email@hidden>)

  • Prev by Date: Avoiding cyclic header imports
  • Next by Date: -layout not called after invoking -setNeedsLayout:YES
  • Previous by thread: Avoiding cyclic header imports
  • Next by thread: -layout not called after invoking -setNeedsLayout:YES
  • Index(es):
    • Date
    • Thread