#IUO UIStoryboardSegue.identifier property should be Optional
| Originator: | kristopherdjohnson |
|
| Number: | rdar://18213186 |
Date Originated: | 03-Sep-2014 08:07 AM |
| Status: | Closed/Fixed |
Resolved: | Fixed |
| Product: | Developer Tools |
Product Version: | Xcode 6 Beta 7 |
| Classification: | Serious Bug |
Reproducible: | Always |
Summary:
The Swift interface for UIStoryboardSegue declares the "identifier" property like this:
var identifier: String { get }
However, this value can be nil, so it should be declared as an Optional
Steps to Reproduce:
Create a new iOS project using the single-view template
Add a second view controller to the storyboard
Add a button to the first view controller, and create a "show" segue from that button to the second view controller. Leave the segue's "Identifier" field unset (blank).
Add an override of UIViewController.prepareForSegue to the first view controller that tries to use the segue.identifier property, like this:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Crash here because segue.identifier is nil, but not Optional
if segue.identifier == "Doesn't matter" {
println("OK")
}
}
Run the app and tap the button. The result is EXC_BAD_ACCESS on the line that attempts to use segue.identifier.
Expected Results:
The "identifier" property should be declared as an optional, so that it can be checked for nil before attempts to use its value.
Actual Results:
Not Optional, so can't check for nil
Version:
Xcode 6 beta 7 (6A280n); OS X 10.9.4
Notes:
Demo Xcode project attached. Run it and tap the button, and it will crash in ViewController.prepareForSegue, as described in the Steps to Reproduce section above.
Configuration:
OS X
Attachments:
'KDJStoryboardSegueIdentifierNullCrash.zip' was successfully uploaded.
----
Apple Developer Relations 29-Sep-2014 06:55 PM
We believe this issue has been addressed in the latest Xcode 6.1 beta.
This pre-release version of the Xcode 6.1 developer tools is required when developing for OS X Yosemite, and includes the Swift programming language. Xcode 6.1 beta runs on OS X Mavericks and OS X Yosemite Developer Preview.
Xcode 6.1 beta - Build 6A1042b
Duplicates
Comments
ag9zfm9wZW5yYWRhci1ocmRyEgsSBVJhZGFyGICAgMD9raMKDA
Please note:
Reports posted here will not necessarily be seen by Apple.
All problems should be submitted at bugreport.apple.com before they are posted here.
Please only post information for Radars that you have filed yourself, and please do
not include Apple confidential information in your posts. Thank you!