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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:48:12+00:00 2026-05-24T06:48:12+00:00

Is there any difference in doing @class MyViewController; rather than doing the normal import

  • 0

Is there any difference in doing

@class MyViewController;

rather than doing the normal import of the .h into the appdelegate.h

#import "MyViewController.h"

I’ve seen some example recently that use the @class way and wondered if there any differences.

thanks.

  • 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-24T06:48:13+00:00Added an answer on May 24, 2026 at 6:48 am

    There is a big difference.

    @class MyViewController;
    

    Is a forward declaration for the object MyViewController. It is used when you just need to tell the compiler about an object type but have no need to include the header file.

    If however you need to create an object of this type and invoke methods on it, you will need to:

    #import "MyViewController.h"
    

    But normally this is done in the .m file.

    An additional use of forward declarations is when you define a @protocol in the same header file as an object that uses it.

    @protocol MyProtocolDelegate; //forward declaration
    
    @interface MyObject {
        id<MyProtocolDelegate> delegate;
        ...
    }
    ...
    @end
    
    @protocol MyProtocolDelegate
        ... //protocol definition
    @end
    

    In the above example the compiler needs to know that the @protocol MyProtocolDelegate is valid before it can compile the MyObject object.

    Simply moving the protocol definition above MyObject definition would also work.

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

Sidebar

Related Questions

Is there any difference to the following code: class Foo { inline int SomeFunc()
Simply put, what are the (or are there any) differences between doing say class
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
Is there any difference between: if foo is None: pass and if foo ==
Is there any difference between a volatile Object reference and AtomicReference in case I
Is there any difference between website and web application project? What if you are
is there any difference between: lock((IDictionary) _collection).SyncRoot) or lock(_collection)
Is there any difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout in .NET?
Is there any difference in using login_required decorator in urls.py and in views.py ?
Is there any difference or associated risk opening with the following PHP variations? <?

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.