IB在IBAction,IBOutlet等中意味着什么? [英] What does IB mean in IBAction, IBOutlet, etc..?

查看:113
本文介绍了IB在IBAction,IBOutlet等中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发的新手。我经常在阅读Objective-C和Swift代码时遇到 IBAction IBOutlet 等等。 IB 代表什么?

I am very new to iPhone development. I often encounter IBAction, IBOutlet and so on when reading Objective-C and Swift code. What does IB stand for?

推荐答案

Interface Builder。

"Interface Builder".

在Xcode 4之前,接口文件(XIB和NIB)是在一个名为Interface Builder的独立程序中编辑的,因此是前缀。

Before Xcode 4, the interface files (XIBs and NIBs) were edited in a separate program called Interface Builder, hence the prefix.

IBAction 定义为 void IBOutlet

IBAction is defined to void, and IBOutlet to nothing. They are just clues to Interface Builder when parsing files to make them available for connections.

只需添加引用,在AppKit / NSNibDeclarations.h中你会发现:

Just to add the reference, inside AppKit/NSNibDeclarations.h you'll find these:

#ifndef IBOutlet
#define IBOutlet
#endif

#ifndef IBAction
#define IBAction void
#endif

所以,实际上,代码就像这个:

So, actually, code like this:

@interface ...
{
    IBOutlet NSTextField *label;
}
- (IBAction)buttonPressed:(id)sender;
@end

将转换为:

@interface ...
{
     NSTextField *label;
}
- (void)buttonPressed:(id)sender;
@end

通过预处理器,甚至在编译器看到它之前。这些关键字就像Interface Builder一样。

By the preprocessor, even before the compiler sees it. Those keywords were acting just as clues to Interface Builder.

这篇关于IB在IBAction,IBOutlet等中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆