本文介绍了类未读...未知类型名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定发生了什么或我改变了什么,但突然一个类,我试图引用那是在项目树和文件夹中(当我在finder中显示)正在读取...我在同一行代码上遇到多个错误[见附件]。

I'm unsure what is going on or what I changed, but all of a sudden a class I'm trying to reference "that is in the project tree" and in the folder (when I "show in finder") isn't being read at all ... I get multiple errors on the same line of code [see attached].

请帮助!

当我尝试将HomeViewController.h导入我的MainContainerViewController时会出现此问题

The issue occurs when I try to import HomeViewController.h into my MainContainerViewController

Works:

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

@interface MainContainerViewController : UIViewController {

ViewController *parent;

NSString *FACING;
IBOutlet UIView *container;

IBOutlet UIView *topNav;

IBOutlet UIButton *homeBTN;
IBOutlet UIImageView *homeImg;
IBOutlet UILabel *homeLabel;
IBOutlet UIImageView *seperator1;
IBOutlet UIButton *bookmarksBTN;
IBOutlet UIImageView *bookmarksImg;
IBOutlet UILabel *bookmarksLabel;
IBOutlet UIImageView *seperator2;
IBOutlet UIButton *favouritesBTN;
IBOutlet UIImageView *favouritesImg;
IBOutlet UILabel *favouritesLabel;
IBOutlet UIImageView *seperator3;
IBOutlet UIButton *notesBTN;
IBOutlet UIImageView *notesImg;
IBOutlet UILabel *notesLabel;
IBOutlet UIImageView *seperator4;
IBOutlet UIButton *fontBTN;
IBOutlet UIImageView *fontImg;
IBOutlet UILabel *fontLabel;
IBOutlet UIImageView *seperator5;
IBOutlet UIButton *settingsBTN;
IBOutlet UIImageView *settingsImg;
IBOutlet UILabel *settingsLabel;

NSString *drawerIsAnimating;

//SETTINGS (LOCAL)
NSString *fontSize;

等。

p>

Broken:

#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "HomeViewController.h"

@interface MainContainerViewController : UIViewController {

ViewController *parent;

NSString *FACING;
IBOutlet UIView *container;

IBOutlet UIView *topNav;

IBOutlet UIButton *homeBTN;
IBOutlet UIImageView *homeImg;
IBOutlet UILabel *homeLabel;
IBOutlet UIImageView *seperator1;
IBOutlet UIButton *bookmarksBTN;
IBOutlet UIImageView *bookmarksImg;
IBOutlet UILabel *bookmarksLabel;
IBOutlet UIImageView *seperator2;
IBOutlet UIButton *favouritesBTN;
IBOutlet UIImageView *favouritesImg;
IBOutlet UILabel *favouritesLabel;
IBOutlet UIImageView *seperator3;
IBOutlet UIButton *notesBTN;
IBOutlet UIImageView *notesImg;
IBOutlet UILabel *notesLabel;
IBOutlet UIImageView *seperator4;
IBOutlet UIButton *fontBTN;
IBOutlet UIImageView *fontImg;
IBOutlet UILabel *fontLabel;
IBOutlet UIImageView *seperator5;
IBOutlet UIButton *settingsBTN;
IBOutlet UIImageView *settingsImg;
IBOutlet UILabel *settingsLabel;

NSString *drawerIsAnimating;

//SETTINGS (LOCAL)
NSString *fontSize;

等。

推荐答案

您可能有标题导入循环。

You may have a header import cycle.

添加

@class MainContainerViewController2;

之前

@interface HomeViewController2

应该解决这个问题。

根据经验,如果你没有绝对的需要,你不应该在头文件中#import头。超类头。如果你需要使用一个类,用@class声明它,而不是导入类头。这样做,你应该99%的时间是安全的。

As a rule of thumb, you shouldn't #import headers in headers if you do not have an absolute need to do so, ie. a superclass header. If you need to use a class, declare it with @class instead of importing the class header. Do that and you should be safe 99% of the time.

这篇关于类未读...未知类型名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:58