Sorry, couldn\'t find a more appropriate title.
In My code I have two classes which should know of each others existence. So I use an instance variable which points to t
In the header, use forward declaration:
@class IRCConnection;
@interface MainMenuController : NSViewController {
IRCConnection *ircConnection; // ok
}
In the source file (.m
), do #import
.
you could remove the import from IRCConnection.h
and use a @class
statement instead.
like this:
#import <Foundation/Foundation.h>
@class MainMenuController;
@interface IRCConnection : NSObject {
then add a #import "MainMenuController.h"
to IRCConnection.m
You cannot have circular imports. You need to break them up, or introduce some forward declarations.