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
7
votes
6 answers

Reasons for an IBOutlet to be nil

What are the reasons why an IBOutlet (connected) could be nil? I have one in may application which is always nil, even if I recreate everything from scratch (declaration and control).
AP.
  • 5,205
  • 7
  • 50
  • 94
7
votes
4 answers

How to initialize a variable when IBOutlet is initialized?

It happened for me to write following code snippet in one of my UIViewControllers in my new iOS Swift Application. var starButtonsCount = starButtons.count @IBOutlet var starButtons: [UIButton]! Then straight next to the starButtonsCount variable…
Randika Vishman
  • 7,983
  • 3
  • 57
  • 80
7
votes
3 answers

Private IBOutlets Swift

I know that our IBOutlets should be private, but for example if I have IBOutlets in TableViewCell, how should I access them from another ViewController? Here is the example why I'm asking this kind of question: class BookTableViewCell:…
Latenec
  • 408
  • 6
  • 21
7
votes
4 answers

Nib IBOutlet causes app to crash

Really need your help! I've been through every possible post addressing this issue and nothing seems to work. So I'm using a .xib file to create a subview within ProfileFoldingCellView.swift, which works perfectly until I attempt to add an IBOutlet…
Yoli Meydan
  • 161
  • 1
  • 5
7
votes
4 answers

how can I distinguish whether user tapped the UIButton quickly or put and hold it in Swift?

I'm creating a camera app in swift and I have a UIButton. I want to propose two options: when user single taps the button - it takes photo and when user holds his finger on a button - it records the movie until user releases the button. I have…
user3766930
  • 5,629
  • 10
  • 51
  • 104
7
votes
2 answers

XCode crashes when I try to drag and drop an IB Outlet

When I try to drag and drop an IB outlet from a UIView into my ViewController.swift, XCode crashes (when I press OK after typing a name for the IBOutlet). A popup appears saying: "XCode quit unexpectedly": Ignore, report, reopen. The report says…
Josh
  • 6,251
  • 2
  • 46
  • 73
7
votes
7 answers

IBOutlets and IBactions require ! in the end

I tried to start and go from Obj-C to Swift today and I was reading the documentation. I tried to create an easy IBOutlet in Swift and it constantly gave me those errors. View Controller has no initialiser required init(coder aDecoder: NSCoder) { …
Julian E.
  • 4,687
  • 6
  • 32
  • 49
7
votes
4 answers

NSScrollview not scrolling programmatically?

Note:Both Horizontal and vertical scrollers are visible on the screen and work fine.But I cant make them move Programatically. I am working on a cocoa desktop application.I am using the NSScrollview in my Mainmenu.xib file and I am creating an…
zzzzz
  • 1,209
  • 2
  • 18
  • 45
7
votes
3 answers

IBOutlets strong or weak

Outlets can be created like this @interface SearchViewController : UIViewController { IBOutlet UIView *viewSearchBar; IBOutlet UIScrollView *scrollVieww; IBOutlet UILabel *lblName; } and also like…
Raheel Sadiq
  • 9,847
  • 6
  • 42
  • 54
7
votes
2 answers

Should IBOutlets be ivars or properties?

Though I'm sure they exists, I'm having difficulties finding or pinning down an official best practice for declaring outlets in a ViewController. There are 3 options so far as I can see: ivar only property only property backed with an ivar Xcode…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
6
votes
2 answers

How to connect an IBOutlet from an UITableViewController directly to custom cell?

A few days ago, I watched the video tutorial which explains how to use custom cells in an UITableViewController. I've learned that I can prepare a custom cell directly in the interface builder, so I did following: I created a UITableViewController…
Tobias Bambullis
  • 736
  • 5
  • 17
  • 45
6
votes
2 answers

Does readonly property for IBOutlet Work and would it be Preferable?

In code that I'm inheriting, I've seen the following: @property (readonly) IBOutlet UIImageView * bgImage; When I would expect a retain memory model like: @property (readonly, retain) IBOutlet UIImageView * bgImage; I'm confused why the first…
Sam
  • 26,946
  • 12
  • 75
  • 101
6
votes
1 answer

iOS - Naming Convention for IBOutlets

I did search around and I found a bunch of conventions but none talk about IBOutlets. Which one of the following should I use? @IBOutlet weak var price: UITextField! @IBOutlet weak var priceTextField: UITextField! @IBOutlet weak var textFieldPrice:…
Marcelo
  • 1,176
  • 1
  • 10
  • 29
6
votes
2 answers

How to loop through view outlets in a UIViewController with Swift?

I'm wondering, if it's possible to loop through all the outlets of a UIViewController with Swift. Specifically, I want to check if every textfield is filled by the user.
twofish
  • 354
  • 4
  • 16
6
votes
2 answers

How to find the UI element connected to a specific IBOutlet?

Is there any way to find which UI element an IBOutlet declared in code is connected to?