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

  • Home
  • SEARCH
  • 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 9076933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:13:08+00:00 2026-06-16T19:13:08+00:00

Possible Duplicate: How can I solve this Problem with bidirectional dependencies in Objective-C classes?

  • 0

Possible Duplicate:
How can I solve this Problem with bidirectional dependencies in Objective-C classes?

Why am I getting a “Parse Issue – Expected a Type” with the following code and what can I do to get it resolved (without changing the API of my test functions)?

// ClassA.h

#define CLASSA_H

#import <Foundation/Foundation.h>
#ifndef CLASSB_H
#import "ClassB.h"
#endif

@interface ClassA : NSObject {}

- (void)test:(ClassB *)input;  // Compiler error: Expected ClassB to be a type

@end

and

// ClassB.h

#define CLASSB_H

#import <Foundation/Foundation.h>
#ifndef CLASSA_H
#import "ClassA.h"
#endif

@interface ClassB : NSObject{}

- (void)test:(ClassA *)input;  // Compiler error: Expected ClassA to be a type

@end

Based on what I read about import vs. include, I shouldn’t even have to use the CLASSA_H and CLASSB_H macros to prevent self-inclusion, but no matter whether I use them or not, I get the very same error.

My actual code is more complex than the sample above, but it boils down to my having two classes whose interfaces reference each other, thus requiring each header to include the other one as in the example above. This is a common situation in C and I don’t get what I am missing here.

  • 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-06-16T19:13:09+00:00Added an answer on June 16, 2026 at 7:13 pm

    You don’t need to include either header. Use a forward declaration.

    // ClassA.h
    
    #import <Foundation/Foundation.h>
    
    @class ClassB;
    
    @interface ClassA : NSObject {}
    
    - (void)test:(ClassB *)input;
    
    @end
    

    and

    // ClassB.h
    
    #import <Foundation/Foundation.h>
    
    @class ClassA;
    
    @interface ClassB : NSObject {}
    
    - (void)test:(ClassA *)input;
    
    @end
    

    Depending on your situation, you might also need to #import "ClassA.h" inside of ClassB.m, and vice-versa. But that won’t cause any additional problems.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Can we solve the table row background image problem, in chrome, in
Possible Duplicate: Can you animate a height change on a UITableViewCell when selected? This
Possible Duplicate: Problem installing my Android apps Any body can tell me how can
Possible Duplicate: Passing char pointer from C# to c++ function I have this type
Possible Duplicate: Difference between session_register and $_SESSION[] this might sound weird but my problem
Possible Duplicate: jasper ireport field length problem I'm working on this web application done
Possible Duplicate: Why can't decimal numbers be represented exactly in binary? problem with floating
Possible Duplicate: Can I run from command line program created by Eclipse? I am
Possible Duplicate: Can I scroll a ScrollView programmatically in Android? I have a chat

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.