#IUO: UIStoryboardSegue.identifier should be of optional type in Swift
| Originator: | invalidname | ||
| Number: | rdar://18469761 | Date Originated: | 9/26/14 |
| Status: | Duplicate/18213186 | Resolved: | 10/2/14 |
| Product: | iOS SDK | Product Version: | 8.0 |
| Classification: | crash/hang/data loss | Reproducible: | always |
Summary:
UIStoryboardSegue's identifier property is of the non-optional String type in Swift. However, failing to assign an identifier in Interface Builder creates a nil identifier, which crashes if inspected in prepareForSegue().
Steps to Reproduce:
Run the attached SegueAndDie project. Key points of this project:
* Two scenes, first has a single button that segues to the second. The segue is not named (different from being blank / empty string: I have never looked at the inspectors for the segue).
* The first scene's ViewController implements prepareForSegue() to look at the identifier:
if segue.identifier.utf16Count > 0 {
println ("Oh good, you named your segue");
}
Expected Results:
App navigates to the second scene
Actual Results:
Crash: EXC_BAD_ACCESS (code=1, address = 0x00)
#2 0x00000001027eff1c in SegueAndDie.ViewController.prepareForSegue (SegueAndDie.ViewController)(ObjectiveC.UIStoryboardSegue, sender : Swift.Optional<Swift.AnyObject>) -> () at /Users/cadamson/dev/apple-buglets/SegueAndDie/SegueAndDie/ViewController.swift:24
Version:
Xcode Version 6.0.1 (6A317)
Notes:
// this crashes too
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var identOpt : String? = segue.identifier
if let ident = identOpt {
if segue.identifier.utf16Count > 0 {
println ("Oh good, you named your segue");
}
}
}
Configuration:
Mac Pro Early 2008, OS X 10.9.4
Attachments:
'SegueAndDie.zip' was successfully uploaded.
Comments
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!