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 7164473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:04:52+00:00 2026-05-28T14:04:52+00:00

I created two classes in objective c and I would like to use one

  • 0

I created two classes in objective c and I would like to use one of them as a property of the other. To be more concrete, one of the classes is a ‘term’ that contains an integer variable and an nsstring that acts as the variable. The other class is an ‘expression’ that has an nsmutable array as an instance variable that contains ‘terms’ as its objects. What I want to do is have add the possibility of having one of the terms have an ‘expression’ as a property to implement something like distributing over parentheses and substituting an expression for a variable. However, Xcode is telling me that ‘expression’ is not an acceptable type name despite the fact that I have imported my expression header file. I think I may have read somewhere that only foundation classes are available to use as properties. What can I do to add this class as an instance variable?

  • 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-28T14:04:53+00:00Added an answer on May 28, 2026 at 2:04 pm

    I suspect you have an import cycle, like this:

    Expression.h

    #import "Term.h"
    
    @interface Expression : NSObject
    ...
    

    Term.h

    #import "Expression.h"
    
    @interface Term : NSObject
    ...
    

    Notice how each file imports the other? That won’t work. Instead, you need to use forward declarations:

    Expression.h

    @class Term;  // tell the compiler that Term is a class name
    
    @interface Expression : NSObject
    ...
    

    Term.h

    @class Expression;  // tell the compiler that Expression is a class name
    
    @interface Term : NSObject
    ...
    

    Then, in your .m files, you can safely import both .h files:

    Expression.m

    #import "Expression.h"
    #import "Term.h"
    
    @implementation Expression
    ...
    

    Term.m

    #import "Term.h"
    #import "Expression.h"
    
    @implementation Term
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created two classes, with one of them having an implicit cast between them:
I want to blit surfaces that I've created in two classes. One is called
I have created two classes that implement AuthorizeAttribute . One is used globally, and
I have created two JavaScript files. One file is "validators.js" and the other is
I've created two classes in business layer. the first one is called Users with
I have an Objective-C++ file, and I have two classes: one Objective-C, one C++:
I have created two classes, class A that uses a Linked List and class
I'm having trouble trying to implement a shared method/property between two classes created by
Say I have two classes created work and workItem. CWorker *work = new CWorker();
I have created a debugger visualizer in VS2008. There are two classes i've made,

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.