Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with object communication



If MainController and MainWindowController depend on each other, the way to avoid circular dependencies is to use the @class directive in the header files, and import headers only in the implementation files. The @class directive tells the compiler that the indicated symbol will be used as a class name, with details to be supplied later.

=====
MainController.h:

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

@interface MainController : NSObject {
MainWindowController * window;
...

=====
MainWindowController.h:

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

@interface MainWindowController : NSWindowController {
MainController * parent;
...

=====
MainController.m:

#import "MainWindowController.h"

@implementation MainController
....

=====
MainWindowController.m:

#import "MainController.h"

@implementation MainWindowController
....


-- F

On Saturday, November 30, 2002, at 11:42 AM, Ferdinand Svehla wrote:

The problem is that i get compiler errors (parse error before) - i think it is because i include in MainController.h in MainWindowController.h and MainWindowController.h in MainController.h (so that the compiler knows which object is capable of doing what)


--
Fritz Anderson - Consulting Programmer - Chicago, IL
Mail: <email@hidden>
Risumi: <http://resume.manoverboard.org>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Problem with object communication (From: Ferdinand Svehla <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.