Re: Help with recursive includes
Re: Help with recursive includes
- Subject: Re: Help with recursive includes
- From: Quincey Morris <email@hidden>
- Date: Sat, 21 Feb 2009 17:44:45 -0800
On Feb 21, 2009, at 17:36, Quincey Morris wrote:
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.
Sorry, I didn't read down into all the nested quotes. You already got
this far. This missing piece is that you have to explicitly #import
*both* .h files into *both* .m files. Alternatively, each .h file
could #import the other, but would still need the appropriate @class
statement to declare the class before it's referred to.
_______________________________________________
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