我是新来的Objective-C,目前正在按照本书中的教程向我展示如何将新视图和视图控制器添加到现有窗口。当我尝试添加一个新的视图控制器时,Xcode给了我一个错误
这本书在这一点告诉我:
"Add a TestViewController instance to your code and label it as an IBOutlet. We are putting it in the app delegate class, TestAppDelegate. In TestAppDeligate.h the new code will look like this:
IBOutlet TestViewController* testViewController;
"
所以,当我改变我的应用程序委托头文件包含此行代码它看起来像这样。
#import <UIKit/UIKit.h>
#import "TestViewController.h"
@class views_and_controllersViewController;
@interface views_and_controllersAppDelegate : NSObject
<UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet
views_and_controllersViewController *viewController;
IBOutlet TestViewController* testViewController;
@end
但是在这一点上的Xcode抛出我的错误:
Cannot declare variable inside @interface or @protocol
以及警告:
iboutlet attribute can only be applied to instance variables or properties
我没有失败注意到,所有其他实例声明中头文件的前缀是@property标签。这是必需的吗?如果是这样的话,那么这本书就会忽略这一点,并期望我已经知道Obj-C期待这样?
Anywho,我在这里做错了什么?
谢谢。像魅力一样工作。 –