Questions tagged [iboutlet]

The type qualifier IBOutlet is a tag applied to an instance-variable declaration so that the Interface Builder application can recognize the instance variable as an outlet and synchronize the display and connection of it with Xcode.

An outlet is an object instance variable — that is, an instance variable of an object that references another object. With outlets, the reference is configured and archived through Interface Builder. The connections between the containing object and its outlets are reestablished every time the containing object is unarchived from its nib file. The containing object holds an outlet as an instance variable with the type qualifier of IBOutlet.

Example:

IBOutlet NSArray *keywords;

Because it is an instance variable, an outlet becomes part of an object’s encapsulated data. But an outlet is more than a simple instance variable. The connection between an object and its outlets is archived in a nib file; when the nib file is loaded, each connection is unarchived and reestablished, and is thus always available whenever it becomes necessary to send messages to the other object. The type qualifier IBOutlet is a tag applied to an instance-variable declaration so that the Interface Builder application can recognize the instance variable as an outlet and synchronize the display and connection of it with Xcode.

903 questions
11
votes
4 answers

EXC_BAD_ACCESS (code=2) when using NSNumberFormatter

I'm having a problem, which I can't figure out for the life of me. I've searched the internet, trying to understand Swifts's EXC_BAD_ACCESS, but nothing seemed to help. The following code is quite long, but most of the time the comments are all the…
Marcus Rossel
  • 3,196
  • 1
  • 26
  • 41
10
votes
5 answers

iOS - What is best way to manage memory for IBOutlets?

I've been reviewing the Apple docs and sample code to try to determine the best way to manage memory for IBOutlets. I'm a little confused, to say the least. The CurrentAddress sample code declares IBOutlets as properties: @interface…
Vega
  • 105
  • 1
  • 4
10
votes
4 answers

IBOutlet and IBAction in Swift

I connected a IBOutlet and IBAction to my button variable from Interface Builder to my View Controller. How do I add an action method to the button in Swift? This code doesn't seem to work. @IBOutlet var OK: UIButton! @IBAction func OK(sender:…
linux-user
  • 131
  • 1
  • 2
  • 4
10
votes
2 answers

How to connect an IBOutlet and IBAction to a View Controller without using the Assistant editor

I know the second button here shows the Assistant editor: And I know how to make an Outlet and Action by Control dragging from an object in the Interface Builder to the View Controller code. Ideally it should be as easy as the documentation makes…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
10
votes
3 answers

Swift, iboutlet and custom controls

I may be doing something really stupid, but I don't seem to be able to use Interface Builder to connect IBOutlet variables to custom views, but only in Swift. I've created a class called MyView, which extends from UIView. In my controller, I've got…
hobart
  • 103
  • 1
  • 1
  • 4
10
votes
2 answers

Create IBOutlets and IBActions programmatically

I want to create IBOutlets and IBActions in code rather than with the interface builder. Let's say I've got a button on my UI called btnDisplay, and a method in my code called displayMessage. What would be the code I'd have to write to make it so…
user3705416
  • 115
  • 1
  • 5
9
votes
2 answers

Why is an IBOutletCollection pointing to static cells from storyboard returning null?

I have defined this in code: @property (nonatomic, weak) IBOutletCollection(UITableViewCell) NSSet * certaintyCells; and synthesized. I made absolutely sure that this controller is used in story board, and connected three cells to this collection.…
Alex Gosselin
  • 2,942
  • 21
  • 37
9
votes
0 answers

Missing IBOutlets in GADUnifiedNativeAdView in xcode 12

I've been trying to implement native Google adMob ads in my iOS app. This is the tutorial I'm following: https://developers.google.com/admob/ios/native/advanced I successfully installed the pod 'Google-Mobile-Ads-SDK'. The tutorial then says to give…
9
votes
2 answers

Is it possible to create an @IBOutlet in a custom view?

I've created a view on the storyboard in one of my view controllers and realized that I'll need to reuse it. So I then created a subclass for UIView to consolidate the code. I've selected the view in the storyboard and changed the class to my custom…
u84six
  • 4,604
  • 6
  • 38
  • 65
9
votes
5 answers

Interface Builder won't allow connections to custom UIView class?

Using Xcode 4.3.3, I can't figure out how to connect outlets in a custom UIView class with objects created in Interface Builder. In one ViewController, I have a variety of buttons, sliders, etc that I'm trying to group into Views. So, within that…
Thunk
  • 4,099
  • 7
  • 28
  • 47
8
votes
2 answers

Can I connect multiple objects with different tags to the same IBOutlet?

I have 30 buttons in one view in Interface Builder. Each has a different tag between 100001 and 100030. I've found it easy to use the same action for each button, passing along the tag for each one when pressed and using code to decide which level…
SW_Cali
  • 383
  • 2
  • 17
8
votes
5 answers

IBOutlet best practices

I would like to know which place is best for placing the IBOutlets from storyboards: a) In the header file (.h) b) In a class extension created on the .m file Thank you Regards
apinho
  • 2,235
  • 3
  • 25
  • 39
8
votes
3 answers

Launch screen is black when set to a storyboard file

I am using a storyboard to get the correct height of a navigation bar in my launch image. However, after customizing the view controller a bit, it now displays a black screen instead of a launch image. When I set it to a brand new view controller,…
Senseful
  • 86,719
  • 67
  • 308
  • 465
8
votes
2 answers

Can you hard code IBActions and IBOutlets, rather than drag them manually in Interface Builder?

Is it possible to to hard code the IBActions and IBOutlets in code, instead of drag-connecting them in Interface Builder?
daihovey
  • 3,485
  • 13
  • 66
  • 110
7
votes
4 answers

Detect which button is pressed with an UIButton Array

I have an UIButton array like this: @property (nonatomic, retain) IBOutletCollection(UIButton) NSArray *btn_Impact_Collection; and I have this function: - (IBAction)impactAction:(id)sender; In the XIB file I have nine button, each button is…
benza
  • 307
  • 1
  • 3
  • 13