获得期望类型的解析错误

时间:2013-02-20 20:30:10

标签: ios objective-c

我使用以下代码创建一个静态方法来返回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];
}

1 个答案:

答案 0 :(得分:2)

#import "DashboardMainMenuViewController.h"或使用@class DashboardMainMenuViewController声明对它的前向引用。编译器只知道导入标头中定义的类型或前向声明的类型