【问题标题】:self "not a structure or a union" in a UIViewController class. Why?UIViewController 类中的 self “不是结构或联合”。为什么?
【发布时间】:2009-10-01 00:48:43
【问题描述】:

我花了很多时间试图找出问题所在......但没有成功。

我的代码如下:

ResultGoalViewController *resultGoalViewController = [[ResultGoalViewController alloc] initWithNibName:@"ResultGoalViewController" bundle:nil];

[self.goalNavigationController pushViewController:resultGoalViewController animated:YES];

我得到错误: “错误:请求成员 'goalNavigationController' 不是结构或联合。”

我的课程是 UIViewController。 goalNavigationController 是一个导航控制器(在选项卡控制器中定义)。

我错过了什么?

【问题讨论】:

    标签: iphone objective-c iphone-sdk-3.0 properties


    【解决方案1】:

    goalNavigationController 应该是 UIViewController 子类中的属性或访问器。

    【讨论】:

    • 别忘了分号!
    【解决方案2】:

    听起来self 没有goalNavigationController 属性。如果是这样,您应该在声明的位置发布,以便我们看到。

    【讨论】:

      【解决方案3】:

      感谢查克,感谢米帕迪。

      我在委托应用程序中有一个 goalNavigationController 属性。

      @interface MyAppDelegate : NSObject <UIApplicationDelegate> {
      UIWindow *window;
      UITabBarController *mytabBarController;
      NavigationGoalViewController *goalNavigationController; 
      

      }

      @property (nonatomic, retain) IBOutlet UIWindow *window;
      @property (nonatomic, retain) NavigationGoalViewController *goalNavigationController;
      
      @end
      

      但它不在我当前的 UIViewController 类中,因为我的 goalNavigationController 最初是在我的委托应用程序中构建/调用的。我现在从导航的第一个视图的 ViewController 调用它(我正在尝试加载导航控制器的第二个视图)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-01-20
        • 1970-01-01
        • 2018-02-13
        • 1970-01-01
        • 2022-11-02
        • 2013-12-11
        • 1970-01-01
        相关资源
        最近更新 更多