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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:47:31+00:00 2026-06-15T00:47:31+00:00

I know it is proper practice to put a forward class declaration (@class ClassA)

  • 0

I know it is proper practice to put a forward class declaration (@class ClassA) in the .h and #import “ClassA.h” in the .m. And also I know doing that can make compiler compile it later on(until #import it in the .m).

Usually we use @class ClassA in A.h meanwhile add #import ClassA.h in A.m, though the compiler would not compile ClassA in A.h, still compiler have to compile it in the A.m.
So why not use #import in A.h directly?

  • 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-15T00:47:32+00:00Added an answer on June 15, 2026 at 12:47 am

    You almost never use @Class A in A.h. The common practice is to use @Class B in A.h and @Class A in B.h. The reason for this is to avoid circular dependencies in the .h files. If A.h imported B.h and B.h imported A.h, the compiler would explode from the circular dependency.

    Your last sentence seems to be asking why we never import A.h in A.h. I think it’s pretty obvious why that isn’t done.

    Remember, the header file (.h) is meant to tell the world the minimum possible about your declarations. It’s there to tell the compiler – “Hey, we have a class (@interface) with some methods and properties. And those methods use these other classes. We use @class for those other classes because at this point in time we only need to know that there will be such classes eventually. It’s just enough to make the compiler happy so it can do its job. Ultimately, the linker makes the final decision about whether those classes really exist somewhere.

    The source file (.m) needs to do the actual importing because the compiler needs to verify that there really are the methods and properties you are trying to use. But the header file doesn’t call methods and it doesn’t call properties. It simply states – “This stuff exists”.

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

Sidebar

Related Questions

Possible Duplicate: @class May I know the proper use of this I am wondering
Does anybody know a proper, cross-browser way to empty an IFrame? Is about:blank recognized
My apologies if this is a duplicate; I may not know the proper terms
I am interested to know what a proper x (vector matrix or data frame)
I know this is not the proper way to do this, however I am
As you know, the proper way to create a Dom Element in Java is
what is the proper code for this? in div style code. I know how
I know you can not set a key value dynamically, but what about the
I know that somewhere in the history of the internet this must have been
Can anyone suggest some good resources, preferrably free, that I can read to thoroughly

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.