For instance, there is a property in a view controller
@IBOutlet weak var nameLabel: UILabel!
This property is nil
inside viewWillAppear
and viewDidLoad
, so the app crashes at runtime.
It was working fine in Xcode 6 Beta 4. After I switched to Beta 5, it complained about the controller class does not implement its superclass's required members
. So I added
required init(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
}
And that compiler error disappeared. However, the app crashes for unexpectedly found nil while unwrapping an Optional value
because that nameLabel
property is nil
when I try to set its text
.
I read through the release notes and could not figure out how to fix this issue.
I was having the same issue in Beta5. It appears to be a problem where
is not mapping nil to the default nibName. When I changed to an explicit nibName then it worked. Specifically in my case, using the new ?? operator:
caused it to magically work again.
It's a temporary bug. The workaround turns out to be: Declare your view controller in such a way as to override name mangling, like this:
See also: Are view controllers with nib files broken in ios 8 beta 5?
EDIT This bug is fixed in iOS 9 beta 4.