• 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: Help with recursive includes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with recursive includes


  • Subject: Re: Help with recursive includes
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 21 Feb 2009 17:36:06 -0800

On Feb 21, 2009, at 17:12, Aaron Wallis wrote:

While that's always an option, it's not exactly the answer I was hoping to hear :D

The good news is I was able to recreate the file in a considerably smaller scale and have uploaded the source here: http://junk.isnot.tv/test.zip

As you can see, i've got two classes which include each others headers (since they need to call each others methods directly)
I may be breaking some design patterns by doing this, and if so, please point them out - cause they could be the cause of the problem :D


There's obviously something basic i'm doing wrong, otherwise we'd be hearing about this issue all the time.

Nothing wrong, just failing to use @class for its intended purpose. :)

#import <Cocoa/Cocoa.h>
@class ControllerB;

@interface ControllerA : NSObject {
	ControllerB *myController;
	NSArray *fruit;
}

@property (readonly, getter=fruit) NSArray *fruit;
@property (retain) ControllerB *myController;

- (NSArray *)fruit;

@end

#import <Foundation/Foundation.h>
@class ControllerA;

@interface ControllerB : NSObject {
	ControllerA *delegate;
}

@property (retain) ControllerA *delegate;

- (void)doSomethingSpecialWithFruit;

@end

Note that you don't need to include either .h file in the other .h file, although you could if you had some other reason to, once you'd used @class to handle the forward-referencing problem caused by mutual class references.



_______________________________________________

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: Help with recursive includes
      • From: Quincey Morris <email@hidden>
References: 
 >Help with recursive includes (From: Aaron Wallis <email@hidden>)
 >Re: Help with recursive includes (From: Aaron Wallis <email@hidden>)

  • Prev by Date: Re: NSTreeController Content Array as index accessor object -- what is the <Key>?
  • Next by Date: Re: Help with recursive includes
  • Previous by thread: Re: Help with recursive includes
  • Next by thread: Re: Help with recursive includes
  • Index(es):
    • Date
    • Thread