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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:33:04+00:00 2026-05-29T04:33:04+00:00

Here is my code classA.h #import classB.h @interface classA : UIViewController { classB *classb;

  • 0

Here is my code

classA.h

#import classB.h

@interface classA : UIViewController
{
  classB *classb;
}

@property (nonatimic, retain) classB *classb;
@end

classA.m

@implementation classA
@synthesize classb = _classb;

-(void)someMethod
{
  self.classb = [[classb alloc]initWithNibName:@"classb" bundle:nil];
  [self.view.superview addSubview:self.classb.view]; 
  [self.view removeFromSuperview];

}
@end

That code work well. classb view is loaded normally. The problem starts here

classB.h

#import classA.h

    @interface classB: UIViewController
    {
       classA *classa;
    }
    @property (nonatimic, retain) classA *classa;
    @end

Now in classA I get error

Unknown type name classB;

I think the problem is some kind of recursion.
The idea is classA to load classB view and in some point classB to remove self from superview and add classA as view

  • 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-29T04:33:07+00:00Added an answer on May 29, 2026 at 4:33 am

    move the #import classA.h from classB.h to classB.m and add @class classA to the header file of classB

    If you use a class only in an @interface (i.e. you don’t use a @protocol defined in that class header) it’s enough to use the @class SomeClass statement.

    This will prevent circular includes.


    classB.h:

    @class classA;
    
    @interface classB: UIViewController
    {
       classA *classa;
    }
    @property (nonatomic, retain) classA *classa;
    
    @end
    

    classB.m:

    #import "classB.h";
    #import "classA.h";
    
    @implementation classB 
    /* */
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my code: delegate.h #import <UIKit/UIKit.h> @class _4_Control_FunViewController; @interface _4_Control_FunAppDelegate : NSObject <UIApplicationDelegate> {
Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static
Here is the code: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class TestGrid {
Here is a simple piece of code: import java.io.*; public class Read { public
Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame
What is the issue with this code? Here we have two files: classA.h and
Here is some code: class Person def initialize(age) @age = age end def age
Here is the code: class Time { public static void printTime (int hour, int
What am I doing wrong here? Created: CustomTab.h #import <UIKit/UIKit.h> @interface CustomTab : UIView
Here's my code: class Publisher(models.Model): name = models.CharField( max_length = 200, unique = True,

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.