我使用了hareddelegate
方法,在运行应用时,我得到了未知类型名称'ViewController'
;你的意思是'UIViewController'
?然后我使用@class ViewController
,但现在我得到了上述错误,我该如何解决。
我在tableview中使用的@property(nonatomic,strong) nstring *title1;
下面的数据分享到详细视图。
请帮帮我。
#import <UIKit/UIKit.h>
//#import "ViewController.h"
@class ViewController;
#define UIAPPDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
}
@property(strong,nonatomic) NSString *title1;
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic) BOOL isFirstTime;
@property (strong, nonatomic) ViewController *viewController;
//@property(strong,nonatomic) ViewController *viewController;
@property (strong, nonatomic) UINavigationController *navigationController;
@end
//did finish with lanching page.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
isFirstTime = YES;
sleep(3);
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
title1=[[NSString alloc]init];
self.viewController= [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
答案 0 :(得分:2)
在使用.m文件之前,您必须先添加它。
@class将用于通知编译器
“我正在使用viewController类,不要指望我导入.h文件”
编译说
“好的。我没有。但是你必须先导入它,然后在使用它之前让我知道。”
因此,在.m文件中使用它之前,您必须在使用.m文件之前添加/导入它。
#import "ViewController.h"