FAQ Database Discussion Community


When to create an outlet of strong type?

ios,swift,iboutlet,strong-references
When we create an outlet its property is directly set to a weak type. However weak type contains on optional value. I want outlet created to be of strong type so that it always contains a value. But there is memory management issues and can form strong reference cycles. Is...

ios - IBOutlet class init not called and members are nil

ios,iphone,swift,iboutlet
I am trying to add search capabilities to the map based project I am working on in swift on XCode 6. I have added SearchDisplayController to my main view controller, which contains the map. I created a class called MapSearchDisplayController, which implements necessary methods. I also changed Custom Class property...

NSViewController not dealloc'd when outlets are bound

automatic-ref-counting,iboutlet,nsviewcontroller,nsstoryboard
I have the following files: Main.storyboard This is the same as the default storyboard created when creating a new project with a few additions: There is a button in the view which is connected to the button outlet of the view controller (instance of ViewController) and the doTheThing: action on...

Reusing a UITableViewCell's IBOutlets with two different UITableViewControllers

swift,uitableview,code-reuse,iboutlet,tableviewcell
I'm creating a coffee timer as a learning exercise and I want to have a different menu based on the brewing method selected. I'm storing my settings in NSUserDefaults and populating my tables with two separate arrays that look like this: var aero = ([ "Cool Down Time Enabled" :...

swift: weak cannot be applied to an outlet

ios,swift,weak-references,iboutlet,zbar-sdk
I am using libzBar for scanning QRCode in swift but I am getting these errors. . First error is about weak referencing and second is undeclared type. At first I thought I haven't included the ZBarReaderView.h but after checking the file Inspector I found that the files are correctly added...

Custom container: @IBOutlets nil even though view is displaying correctly

ios,swift,iboutlet,uicontainerview
I have created a UIViewController. Within this view controller I have a container view. In the code I instantiate the container view like so: var answerButtons: AnswerButtonsViewController! override func viewDidLoad() { super.viewDidLoad() answerButtons = AnswerButtonsViewController() answerButtons.delegate = self println(answerButtons.name) // This prints out the correct string println(answerButtons.answerOne) // This prints...

Swift, two issues. 1) weak var 2) bang operator for @IBOutlet

swift,operators,automatic-ref-counting,iboutlet
Per: @IBOutlet weak var nameLabel: UILabel! Whenever I declare my IBOutlets, i just use var instead of weak var. But I've recently come across a few code templates that use weak var. Why do they do it? What's the added benefit? Why is there a bang operator at the end...

Is creating an IBOutlet too expensive?

ios,cocoa-touch,iboutlet
A while ago I became a fan of creating/manipulating the view hierarchy through code. Both because I think is more expressive and forces me to learn more about Cocoa. But I just wrote a 5 lines of code which would look way more expressive if an IBOulet was used. It...

IBOutlet declaration place

ios,objective-c,iboutlet
After searching on Google about this confusion, I found out that the best place to put an IBOutlet is: @interface GallantViewController : UIViewController @property (nonatomic, weak) IBOutlet UISwitch *switch; @end but from what I say, now the switch variable is visible outside of the GallantViewController. Isn't that odd? I thought...

How to show subclass of UIControl in View Controller

ios,swift,interface-builder,iboutlet,uicontrol
I would like to be able to interact with the UIControl I have made, and therefore want it in my ViewController. What I tried I subclassed UIControl (1). Then I added a UIView to my View Controller and assigned it the new class (2). But in Interface Builder I am...

IBOutlet of another view controller is nil

swift,nil,iboutlet
I have a storyviewcontroller which has objects on its view. I need to change the text on the UILabel(In the storyviewcontroller) and the load the view on an array. I have connected the IBOutlet to the label in the storyviewcontroller. class StoryViewController: UIViewController { @IBOutlet weak var textLabel: UILabel! @IBOutlet...

Accessing IBOutlet from another class

ios,class,swift,null,iboutlet
I am calling a class function from my ViewController class like this: Buttons.set_cornerRadius(10) I have another .swift file where I have the function declared: class Buttons { class func set_cornerRadius(radius: CGFloat) { ViewController().someButton.layer.cornerRadius = radius } } When I'm trying to run this it throws the error: "Unexpectedly found nil...

Programmatically switching tabBar causes IBOutlet to be nil

ios,swift,delegates,uitabbarcontroller,iboutlet
I am switching tabBar programmatically - which works fine. However, an IBOutlet mapView (google maps) becomes nil - leading to a crash... I've spent quite a few hours on this. Feels like I am missing something trivial. Looked through SO, e.g.: Switch tab bar programatically in Swift and All my...

Instance of class does not initialize IBOutlets in class

xcode,swift,initialization,iboutlet
I have a class called AccountPanelController that contains two variables: an IBOutlet to an NSTableView, as well as a simple Int. When I run my app, awakeFromNib: prints that both the NSTableView and the Int have been initialized. From another file, I have created and initialized an instance of the...

Most efficient way to reference 2 different IBOutlets at once (where each one only exists for it's own size class)?

ios,xcode,iboutlet,size-classes,universal-storyboard
I am currently using unified storyboards (with size classes). For 1 of my views, the difference in design between the wAny hAny and the wRegular hRegular size classes is significant enough that altering the constraints for the subviews based on size class is not enough. A simplified example: I have...