• 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: Problem with object communication
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with object communication


  • Subject: Re: Problem with object communication
  • From: Fritz Anderson <email@hidden>
  • Date: Sat, 30 Nov 2002 12:56:26 -0600

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.

  • Follow-Ups:
    • Re: Problem with object communication
      • From: Ferdinand Svehla <email@hidden>
References: 
 >Problem with object communication (From: Ferdinand Svehla <email@hidden>)

  • Prev by Date: Re: Piping Strangeness
  • Next by Date: Re: Piping Strangeness
  • Previous by thread: Problem with object communication
  • Next by thread: Re: Problem with object communication
  • Index(es):
    • Date
    • Thread