Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does IB mean in IBAction, IBOutlet, etc..?

Tags:

xcode

iphone

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?

like image 460
Aldee Avatar asked Dec 21 '11 15:12

Aldee


People also ask

What is difference between IBOutlet and IBAction?

An IBAction is for hooking a method (action) up to a view when designing your XIB. An IBOutlet lets you reference the view from your controller code. An IBAction lets the view call a method in your controller code when the user interacts with the view.

What are IB outlets?

An IB Outlet (short for Interface Builder outlet) is a graphical component that your code links to. An IB action is the reverse: It is a method in your code that a graphical component links to. It is through these connections that your graphical components are able to do something in response to user input.

What is IBOutlet and IBAction?

@IBAction is similar to @IBOutlet , but goes the other way: @IBOutlet is a way of connecting code to storyboard layouts, and @IBAction is a way of making storyboard layouts trigger code. This method takes one parameter, called sender . It's of type UIButton because we know that's what will be calling the method.

What is IB in IOS?

Interface Builder is a software development application for Apple's macOS operating system. It is part of Xcode (formerly Project Builder), the Apple Developer developer's toolset. Interface Builder allows Cocoa and Carbon developers to create interfaces for applications using a graphical user interface.


2 Answers

"Interface Builder".

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

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.

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 

Will be transformed into:

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

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

like image 157
sidyll Avatar answered Sep 24 '22 10:09

sidyll


IB stands for interface builder, as you connect objects via the interface builder .

like image 30
Ankit Srivastava Avatar answered Sep 20 '22 10:09

Ankit Srivastava