ios5 编程关于@synthesize window = _window的理解
2012-07-24 13:28
411 查看
1 | @synthesizewindow=_window; |
2 | @synthesizeviewController=_viewController; |
window=_window;怎么理解?这里的_window和_viewController是什么变量?
.h文件中在类中没有定义window和viewController
实例变量,怎么能进行@perproty声明呢?
1 | #import<UIKit/UIKit.h><atarget="_blank"rel="nofollow">@class</a>ViewController;<atarget="_blank"rel="nofollow">@interface</a>AppDelegate:NSObject<UIApplicationDelegate> |
2 |
3 | @property(nonatomic,retain)IBOutletUIWindow*window; |
4 | @property(nonatomic,retain)IBOutletViewController*viewController; |
5 | <atarget= "_blank" rel= "nofollow" >@end</a> |
32-bit时,如果类的@interface部分没有进行ivar声明,但有@property声明,在类的@implementation部分有响应的@synthesize,则会得到类似下面的编译错误:
Synthesized
property'xX'musteitherbenamedthesameasacompatibleivarormustexplicitlynameanivar
在
64-bit时,运行时系统会自动给类添加ivar,添加的ivar以一个下划线"_"做前缀。
上面声明部分的@synthesizewindow=_window;
意思是说,window属性为_window实例变量合成访问器方法。
如果不明确的指明私有变量的名称的话,系统就会认为你的私有变量名和属性名是一样的!
相关文章推荐
- ios5 编程关于@synthesize window = _window的理解
- 关于linux socket 编程 端口复用的理解
- MFC编程中SetViewportOrg与SetWindowOrg的理解
- Windows编程中SetViewportOrg与SetWindowOrg的理解
- 关于编程的理解-【学习札记】
- 关于window编程的鼠标消息
- @synthesize window=_window之类的写法的理解
- @synthesize window=_window之类的写法的理解
- JS 关于(function( window, undefined ) {})(window)写法的理解
- ios开发关于多线程编程的理解(一)
- 关于C#里面socket编程的一点理解
- 关于对事件驱动架构(event drive architecture)和事件驱动编程的理解。
- @synthesize window=_window之类的写法的理解
- 关于编程范式的分析与理解
- 关于面向方面编程的理解
- @synthesize window=_window; 的理解
- 我的关于编程中调用系统库的过程始终不理解???这篇文件解析了pe文件的结构
- 关于编程范式的理解
- 我近期原创帖之1(看谁理解更深刻,关于defer,attachEvent,window.onload....)
- @synthesize window=_window; 如何理解?