要求会员不是结构或工会

时间:2011-11-25 19:32:22

标签: objective-c struct properties union

当我试图在uiviewcontroller上设置webview属性时,我遇到了一个问题。 这里是代码:

的UIWebView:

@interface mainView : UIWebView { 
    int currentPage;
}
@property int currentPage;

我合成了实现

的UIViewController

(void)loadView {
    webview = [[mainView alloc]init];
    webview.currentPage = 2; // error -> Request for member "currentPage' in something not a structure or union
    self.view=webview;
    [webview release];
}

为什么我无法设置currentPage属性?

任何人都知道解决方案,所以我可以在UIViewController上设置currentPage吗?

感谢。

1 个答案:

答案 0 :(得分:2)

webviewmainView的实例(顺便提一下,类名应以大写字母开头,因此它应该是MainView),或者它是UIWebView的实例}。看起来您忘记将webview声明为正确的类类型,因为编译器无法识别它具有名为currentPage的属性。