目标c中的未知类型名称 [英] unknown type name in objective c
问题描述
我使用导航器编写了一个简单的程序,一切都正常运行。
然后我添加了几行代码(甚至不记得究竟是什么,似乎没有连接到问题)和问题发生。我试过ctrl + z,问题依然存在:
我运行该程序并得到这些错误:
1。未知类型名称mainController
2.具有retain(或strong)属性的属性必须为对象类型
而mainController是第一个要加载的屏幕。
这是appDelegate.h文件:
#import< UIKit / UIKit.h>
#importmainController.h
#importWishesList.h
#importWish.h
@interface AppDelegate:UIResponder&UIApplicationDelegate>
@property(强,非原子)UIWindow *窗口;
@property(强,非原子)IBOutlet UINavigationController * navController;
@property(strong,nonatomic)IBOutlet mainController * viewController; //这行创建错误
@property(strong,nonatomic)WishesList * WishesArray;
@property(strong,nonatomic)NSIndexPath * temp;
@end
这是appDelegate.m文件的相关部分:
- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
WishesArray = [[WishesList alloc] init];
temp = nil;
[self setViewController:[[mainController alloc] init]];
[self setNavController:[[UINavigationController alloc] initWithRootViewController:self.viewController]];
[self.window setRootViewController:navController];
[self.window makeKeyAndVisible];
返回YES;
}
这是mainController.h:
#import< UIKit / UIKit.h>
#importaddWishController.h
#importdisplayWish.h
#importWishesList.h
#importWish.h
@interface mainController:UIViewController
@property(nonatomic,weak)WishesList * list;
@property(nonatomic,strong)IBOutlet UITableView * wishTable;
- (void)addWish;
@end
它已经工作了...
你能弄清楚吗?
谢谢
这个问题发生在我一次。
我正在导入我的h文件中的APPDelegate.h,并在我的APPDelegate.h中导入文件(它应该是不是一个问题,但...)
我做了什么:我将导入从我自己的.h更改为.m,它的工作原理是:)
I'm pretty new to objective c, and having some basic problems.
I wrote a simple program using a navigator, and everything worked fine. then I added few lines of code (can't even remember what exactly, and it seems to have no connection to the problem) and the problem occurred. I tried ctrl+z, and the problem remained:
I run the program and get these errors:
1. unknown type name "mainController"
2. property with 'retain (or strong)' attribute must be of object type
while mainController is the first screen to be loaded.
This is the appDelegate.h file:
#import <UIKit/UIKit.h>
#import "mainController.h"
#import "WishesList.h"
#import "Wish.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) IBOutlet UINavigationController *navController;
@property (strong, nonatomic) IBOutlet mainController *viewController; // this line creates the errors
@property (strong, nonatomic) WishesList *WishesArray;
@property (strong, nonatomic) NSIndexPath *temp;
@end
this is the relevant part of the appDelegate.m file:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
WishesArray = [[WishesList alloc]init];
temp = nil;
[self setViewController:[[mainController alloc]init]];
[self setNavController:[[UINavigationController alloc]initWithRootViewController:self.viewController]];
[self.window setRootViewController:navController];
[self.window makeKeyAndVisible];
return YES;
}
And this is mainController.h:
#import <UIKit/UIKit.h>
#import "addWishController.h"
#import "displayWish.h"
#import "WishesList.h"
#import "Wish.h"
@interface mainController : UIViewController
@property (nonatomic, weak) WishesList *list;
@property (nonatomic, strong) IBOutlet UITableView *wishTable;
- (void)addWish;
@end
it already worked...
can you figure it out?
thanks
This problem happen to me once.
I was importing the "APPDelegate.h" in my h file and in my APPDelegate.h I was importing the file too (it shouldn't be a problem but...)
What I did: I changed the Import from my own .h to .m and it worked :)
这篇关于目标c中的未知类型名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!