iboutlet
IBOutlet and viewDidUnload under ARC
Just doing a bit of research… As I understand it, weak is similar to assign, in that they’re both weak references. However, assign does not create a zeroing reference. i.e. if the object in question is destroyed, and you access that property, you WILL get a BAD_ACCESS_EXCEPTION. Weak properties are automatically zeroed (= nil) when … Read more
Swift put multiple IBOutlets in an Array
you can define a generic outlet collection in Swift like this: @IBOutlet var collectionOfViews: Array<UIView>? // = [UIView]? or for e.g. UIButton objects: @IBOutlet var collectionOfButtons: Array<UIButton>? // = [UIButton]? you can find your collections under the Outlet Collections group as usually are in the File’s Owner: it would look on my console after connecting … Read more
Connect outlet of a Cell Prototype in a storyboard
UPDATE: As of Xcode 4.6 (possibly earlier) you can now create outlets by control-dragging! – This has to be done into an interface section or class extension (the class extension doesn’t exist by default for new cell subclasses. Thanks to Steve Haley for pointing this out. You can’t get the outlet automatically connected and created … Read more
Make a UIBarButtonItem disappear using swift IOS
Use the property enabled and tintColor let barButtonItem:UIBarButtonItem? = nil if isHidden{ barButtonItem?.enabled = false barButtonItem?.tintColor = UIColor.clearColor() }else{ barButtonItem?.enabled = true barButtonItem?.tintColor = nil }
Strange error when adding items to prototype cells in storyboard-IB
In fact you can’t just make an outlet from a dynamic cell prototype in the UITableView delegate view controller. You’ll have to subclass UITableViewCell and then attribute this class to your prototype. Then you can Ctrl-Drag from the Label to the UITableViewCell subclass header file. Finaly you can access to this outlet in the delegate … Read more
IBOutletCollection set ordering in Interface Builder
EDIT: Several commenters have claimed that more recent versions of Xcode return IBOutletCollections in the order the connections are made. Others have claimed that this approach didn’t work for them in storyboards. I haven’t tested this myself, but if you’re willing to rely on undocumented behavior, then you may find that the explicit sorting I’ve … Read more
Why weak IBOutlet NSLayoutConstraint turns to nil when I make it inactive?
When your outlet is weak, the only strong reference is from the view’s constraints property. Deactivating the constraint removes it from that array, so there are no more strong references.
Xcode Interface Builder – “correct” way to delete/rename miswired IBOutlets / IBActions?
Use the Connections inspector to break the connection. Then you can modify/delete the object and/or the code without having to worry.
UISegmentedControl deselect (make none of the segments selected)
The right way to do this is: [menu setSelectedSegmentIndex:UISegmentedControlNoSegment]; Edit: Swift 5: menu.selectedSegmentIndex = UISegmentedControl.noSegment