Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6339371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:38:13+00:00 2026-05-24T19:38:13+00:00

Sorry, couldn’t find a more appropriate title. In My code I have two classes

  • 0

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 the other class. For that to work (I guess?) the other classes headers file should be imported so it knows which methods it has and such.

Here is my code (stripped down)

MainMenuController.h:

    #import <Cocoa/Cocoa.h>
    #import "IRCConnection.h"

    @interface MainMenuController : NSViewController {    
        IRCConnection *ircConnection;
    }

    @property (strong) IRCConnection *ircConnection;

    @end

IRCConnection.h:

    #import <Foundation/Foundation.h>
    #import "MainMenuController.h"

    @interface IRCConnection : NSObject {

        MainMenuController *mainMenuController;
    }

    @property (strong) MainMenuController *mainMenuController;

    @end

As you can see they both import each other, but this creates an error (Unknown type name ‘IRCConnection’) in one, and in the other Unknown type name ‘MainMenuController’.

However when the connection is just one way (e.g. only MainMenuController knows about IRCConnection) and thus there is only an import statement in one of the two, it works fine.

How can I have them to know about each other? In both ways.

Hope this question makes any sense.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:38:14+00:00Added an answer on May 24, 2026 at 7:38 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the title, I couldn't find the right word. I'll try my best
Sorry I couldn't think of a better title... So I have this database where
Sorry if this is a dupe, couldn't find it but didnt really know what
Sorry about the bad title, I couldn't think of a more descriptive one. The
A question for those familiar with MigLayout sorry couldn't think of a more appropriate
I know the title is vague, sorry I couldn't think of a better way
Sorry for the vague title, couldn't come up with anything more informative %) What
Sorry couldn't think of a better title. :) Here goes, I have been pulling
Sorry I couldn't find the best heading for this question. Following is my requirement.
Sorry if this is a duplicate - couldn't find an answer by searching. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.