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

Avoiding cyclic header imports


  • Subject: Avoiding cyclic header imports
  • From: Erik Stainsby <email@hidden>
  • Date: Tue, 10 Jul 2012 17:01:53 -0700

I have two classes, and a model object - RSPlugin, RSExpression, and RSRule - which share the same data model.
I have thought to have the classes provide a method which can be used to initialize the RSRule object so:

RSRule * rule = [[RSRule alloc] init];
[rule loadFromPlugin: currentPlugin];

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.

The same sort of reciprocal data-swapping interface would be wanted for the RSExpression side of the chain.

I imagine this is such a commonplace sort of relationship that there must be a standard approach (or perhaps several approaches) to solving it.  My first stab at it was to try and provide the interfaces as categories but I ran into a similar issue with circular imports.

Anyone got a pointer to a Comp Sci 101 style description of how to avoid this?  Thanks for your time.

~ Erik
_______________________________________________

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

  • Follow-Ups:
    • Re: Avoiding cyclic header imports
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: turning app into background app
  • Next by Date: Re: Avoiding cyclic header imports
  • Previous by thread: Re: 10.7 Full-Screen transition animation corrupts my UI - how to avoid?
  • Next by thread: Re: Avoiding cyclic header imports
  • Index(es):
    • Date
    • Thread