我使用以下代码创建一个静态方法来返回DashboardMainMenuViewController。在接口.h文件中,我得到一个错误,说明期待类型。
+(DashboardMainMenuViewController *) dashboardMainMenuController;
+(DashboardMainMenuViewController *) dashboardMainMenuController
{
UISplitViewController *splitViewController = (UISplitViewController *) [[[self appDelegate] window] rootViewController];
NSArray *navigationControllers = [splitViewController viewControllers];
NSArray *viewControllers = [[navigationControllers objectAtIndex:0] viewControllers];
return (DashboardMainMenuViewController *) [viewControllers objectAtIndex:0];
}
答案 0 :(得分:2)
#import "DashboardMainMenuViewController.h"
或使用@class DashboardMainMenuViewController
声明对它的前向引用。编译器只知道导入标头中定义的类型或前向声明的类型