Unable to mount output collection in Xcode 6 using storyboard

I'm having trouble creating an output collection in Xcode 6. The output collections in Xcode 6 now function like regular IBOutlets, and you use the same @IBOutlet attribute to declare the release collection without thinking of specifying an array for this type. I did this, in my opinion, a fast file with ie files

@IBOutlet var cardButtons: UIButton[] 

In Xcode 5, when one control drags an item from the storyboard to the appropriate view controller using the helpers editor, they are given the opportunity to create an output or output collection. This seems more impossible in Xcode 6, and my hunch is that the products and the output of the collection now use the same @IBOutlet attribute. How to create a collection of sockets that will contain 10 buttons, without being able to control the drag and drop of each type of storyboard and connect it to mine

 @IBOutlet var cardButtons: UIButton[] 

property in my view controller swift file?

+7
swift xcode6
Jun 05 '14 at 17:15
source share
4 answers

Everything worked out for you, you just need to define the array more formally:

 @IBOutlet var cardButtons: Array<UIButton> 

Now you can connect buttons from IB.




The above should work, but in Xcode 6 beta 3 still doesn't work. A NSArray is to use NSArray until Xcode and Swift handle this correctly:

 class ViewController: UIViewController { @IBOutlet strong var labels: NSArray! override func viewDidLoad() { super.viewDidLoad() for label in self.labels as [UILabel] { label.textColor = UIColor.redColor() } } } 
+10
Jun 05 '14 at 17:32
source share

This is under the well-known issues of Xcode 6: "Interface Builder does not support declaring alumni collections in Swift classes. (15607242)"

Nate Cook's answer is for plugging in, but not for collections. We hope that in the next release of Xcode 6 this problem will be solved.

+2
Jun 23 '14 at 14:01
source share

The following syntax works in seed 3 of Xcode 6:

 @IBOutlet strong var cardButtons: NSArray? 

Please note the following:

  • You should use strong because, by default, @IBOutlet is weak, and since the array is not in the interface, it will disappear before you can use it.

  • You must use NSArray because you cannot mark the array as strong.

Knowing what you have is now up to you.

Note also that this is not the syntax advertised by documents or by Xcode itself when you control the drag and drop to form a collection of output. I can not help it; using this syntax causes a seg error, so it is clear that something else is needed, at least for now.

+2
Jul 10 '14 at 21:27
source share

Strange, I made an IBOutlet with a quick one and it has been working for a while. Just understand that stop working and find out that something broke in the latest beta version of xcode, where it does not work.

0
Jul 05 '14 at 18:52
source share



All Articles