ios5 编程关于@synthesize window = _window的理解
1
@synthesize window=_window;
2
@synthesize viewController=_viewController;
通常看到的都没有包含=部分,@synthesize window=_window; 怎么理解?这里的 _window 和 _viewController 是什么变量?
.h 文件中在类中没有定义 window 和 viewController 实例变量,怎么能进行 @perproty 声明呢?
1
#import <UIKit/UIKit.h> <a href="http://my.oschina.net/liwenlong7758" target="_blank" rel="nofollow">@class</a> ViewController;<a href="http://my.oschina.net/interface" target="_blank" rel="nofollow">@interface</a> AppDelegate : NSObject <UIApplicationDelegate>
2
3 www.2cto.com
@property (nonatomic, retain) IBOutlet UIWindow *window;
4
@property (nonatomic, retain) IBOutlet ViewController *viewController;
5
<a href="http://my.oschina.net/u/567204" target="_blank" rel="nofollow">@end</a>
在 32-bit 时,如果类的 @interface 部分没有进行 ivar 声明,但有 @property 声明,在类的 @implementation 部分有响应的 @synthesize,则会得到类似下面的编译错误:
Synthesized property 'xX' must either be named the same as a compatible ivar or must explicitly name an ivar
在 64-bit时,运行时系统会自动给类添加 ivar,添加的 ivar 以一个下划线"_"做前缀。
上面声明部分的 @synthesize window=_window; 意思是说,window 属性为 _window 实例变量合成访问器方法。
作者:it_machine_
相关新闻>>
- 发表评论
-
- 最新评论 更多>>
今日头条
更多>>您可能感兴趣的文章
- iPhone应用开发之十一:常用的三种动画表现效果
- Android:实现TabWidget选项卡按钮在屏幕下方
- iPhone开发学习笔记006—— NSNotification自定义通知名
- ios开发问题:添加库和复制其它工程文件编译错误问题
- Lexical or Preprocessor Issue 'xxx.h
- Memory on the iPhone
- 多线程之NSInvocationOperation
- (iPhone/iPad开发)presentViewController相应方法在SDK5.0前后
- ios学习笔记(二)xcode 4.3.2下实现基本交互
- iphone开发之object c基础一定义接口