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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:11:49+00:00 2026-05-21T20:11:49+00:00

my xcode 4 just crashed and I get build errors: Unknown type name ‘SecondViewController’

  • 0

my xcode 4 just crashed and I get build errors:

Unknown type name
‘SecondViewController’

in the @interface code block:

SecondViewController *sms;

and

Property with ‘retain’ attribute must
be object type

in

@property(nonatomic,retain) SecondViewController *sms;

However I import SecondViewController.h. The same code worked before the crash.

FirstViewController.h: http://pastebin.com/jnPKBny7

SecondViewController.h: http://pastebin.com/2D058ZAK

Edit: I realized that this error occures because the classes import each other. Can anyone describe why this is wrong?

Any ideas?

  • 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-21T20:11:50+00:00Added an answer on May 21, 2026 at 8:11 pm

    You can’t have circular imports. I think it’s good practice to use forward class declarations with the @class directive whenever possible. For your case:

    FirstViewController.h:

    @class SecondViewController ;
    @interface FirstViewController
    {
        SecondViewController * _secondViewController ;
    }
    
    @property ( nonatomic, retain ) secondViewControlller ;
    
    @end
    

    SecondViewController.h:

    @class FirstViewController ;
    @interface SecondViewController
    {
        FirstViewController * _firstViewController ;
    }
    
    @property ( nonatomic, retain ) firstViewControlller ;
    
    @end
    

    Then in your .m files, import the .h files for the classes you are using. The only reasons to import .h files into other .h files are:

    • framework imports (i.e. )
    • you need to use a protocol
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I build in Xcode, any errors or warnings are being duplicated. So in
I can load, build and run my app with no errors in XCode 4,
Does Xcode support anything akin to Visual Studio style #region directives for arbitrary code
I just installed XCode 3.2.1. When I open the Developer Documentation and click any
I have a NSManagedObject subclass, created by the XCode model interface. This class has
I just installed the new XCode with iPhone SDK 4.0. On my project, I
I've just updated xcode to release 4.0. A lot of the frameworks in my
Just upgraded my xcode to the latest SDK which has the iOS 4.1 SDK.
Having just upgraded to iOS 4.1 (Xcode 3.2.4) I am getting warnings when using
I just spent over an hour due to yet another XCode quirck. I added

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.