Xcode ios Unknown type name?

Fabio picture Fabio · Nov 8, 2012 · Viewed 18.7k times · Source

I have a question about the following error "Unknown type name VistaDereIzq"

I have a view called VistaDereIzq. And I do the following to add that view in this view.

#import <UIKit/UIKit.h> 
#import <MessageUI/MessageUI.h>
#import "VistaDereIzq.h"
#import "ViewController.h"

@interface VistaNavegador : UIViewController  <UIWebViewDelegate>
{ 
    VistaDereIzq *VistaIzq2;   <----- "Unknown type name VistaDereIzq"
}

@end

Answer

justin picture justin · Nov 8, 2012

You probably have a circular dependency/include. Use a forward declaration (@class MONClass;) rather than #importing the header. Since there is no physical dependence, you should be using a forward declaration in the first place (i.e. for much faster builds).

So instead of:

#import "VistaDereIzq.h"

use:

@class VistaDereIzq;

and then add your #import to an .m file as needed.