IBOutlet和IBAction到底是什么?
来源:互联网 发布:php pdo sqlserver 编辑:程序博客网 时间:2024/05/22 00:24
You might be wondering just what IBAction and IBOutlet are. Are they part of the Objective-C language?
Nope. They’re good old-fashioned C pre-processor macros. If you go into the AppKit.framework and look at the NSNibDeclarations.h header file, you’ll see that they’re defined like this:
#ifndef IBOutlet
#define IBOutlet
#endif
#ifndef IBAction
#define IBAction void
#endif
Confused? These two keywords do absolutely nothing as far as the compiler is concerned. IBOutlet gets entirely removed from the code before the compiler ever sees it. IBAction resolves to a void return type, which just means that action methods do not return a value. So, what’s going on here?
The answer is simple, really: IBOutlet and IBAction are not used by the compiler. They are used by Interface Builder. Interface Builder uses these keywords to parse out the outlets and actions available to it. Interface Builder can only see methods that are prefaced with IBAction and can only see variables or properties that are prefaced with IBOutlet. Also, the presence of these keywords tells other programmers, looking at your code in the future, that the variables and methods in question aren’t dealt with entirely in code. They’ll need to delve into the relevant nib file to see how things are hooked up and used.
Nope. They’re good old-fashioned C pre-processor macros. If you go into the AppKit.framework and look at the NSNibDeclarations.h header file, you’ll see that they’re defined like this:
#ifndef IBOutlet
#define IBOutlet
#endif
#ifndef IBAction
#define IBAction void
#endif
Confused? These two keywords do absolutely nothing as far as the compiler is concerned. IBOutlet gets entirely removed from the code before the compiler ever sees it. IBAction resolves to a void return type, which just means that action methods do not return a value. So, what’s going on here?
The answer is simple, really: IBOutlet and IBAction are not used by the compiler. They are used by Interface Builder. Interface Builder uses these keywords to parse out the outlets and actions available to it. Interface Builder can only see methods that are prefaced with IBAction and can only see variables or properties that are prefaced with IBOutlet. Also, the presence of these keywords tells other programmers, looking at your code in the future, that the variables and methods in question aren’t dealt with entirely in code. They’ll need to delve into the relevant nib file to see how things are hooked up and used.
- IBOutlet和IBAction到底是什么?
- IBOutlet 与 IBAction 到底是什么
- IBOutlet和IBAction
- IBOutlet和IBAction
- IBoutlet和IBAction
- IBOutlet和IBAction
- 转:IBOutlet和IBAction
- IBOutlet和IBAction
- IBOutlet和IBAction
- ios_01-----IBAction和IBOutlet
- IBAction和IBOutlet
- IBOutlet 和 IBAction 区别
- storyboard设置IBOutlet和IBAction
- IOS中的IBOutlet 和 IBAction
- IBoutlet和IBAction的使用
- IBOutlet、IBAction
- IBOutlet,IBAction
- IBOutlet,IBAction
- 获取RichEditCtrl图片及如何使用在你的程序中~
- 自定义JavaScript类
- Sql Server内存瓶颈(读书笔记)
- js处理年月日下拉菜单变化
- Java学习笔记四
- IBOutlet和IBAction到底是什么?
- 程序员职业发展的绊脚石-思想的枷锁
- hdu 3952 计算几何
- zoj 1091 Knight Moves (BFS)(情况用循环控制,值得学习啊)
- jquery-复选框的全选与反选及数组的定义
- 关于tinyxml的剖析及遍历
- java的对象复制 --整理总结版
- 单调队列
- 委托和事件