Xc6 and disappearing unwind segues
Xc6 and disappearing unwind segues
- Subject: Xc6 and disappearing unwind segues
- From: Fritz Anderson <email@hidden>
- Date: Mon, 22 Sep 2014 14:29:07 -0500
6.0 (6A313) iOS 8 target using Swift.
The short of it is that I am unable at least to get Interface Builder to recognize a handler for an unwind segue upstream from the scene that would like to use it. It later developed that loading the storyboard would yield a generic view controller (UITableViewController) instead of the intended subclass.
The declaring subclass is specified as the class of the upstream scene. I’ve checked the spelling. I’ve tried specifying the application module, and not. The subclass’s name, and not UITableViewController, appears in the Storyboard content. Starting with the Master-Detail template got the expected behavior (master view controller loaded as subclass, unwind handlers visible in IB). I’ve tried building up from the good project, and down from the bad one, but have yet to find the breaking point.
It should not necessarily motivate you that not finding a solution soon would be of more-than-business consequence to me. Everybody’s problem is urgent. But I’ll say it anyway.
What am I doing wrong?
===
# Background
We’re all familiar with unwind segues. A controller declares an unwind handler like this:
@IBAction func editorDidCancel(segue: UIStoryboardSegue)
{ NSLog("Hit the segue") }
In a storyboard, select a different scene (typically one in a presentation chain from the implementor of the handler), and control-click on the rightmost, red placeholder in the scene’s title bar. A heads-up menu appears, listing editorDidCancel: and any other unwind handlers that a class might have defined.
I can instantiate a master-detail + Core Data project template, put this handler in the master class, and a button in the detail scene's navigation bar. Control-clicking in the detail scene’s Exit proxy shows editorDidCancel: as expected.
But when I create a more-sophisticated project (but with no additional view controllers), the same handlers do not appear.
# IB Doesn’t See the Subclass?
One thing to note: The autocompletion for the class names (Master -> PasserList, Detail -> GameList) does not turn up those classes. The classes had been renamed by a global find-and-replace (which did reach into the storyboard, or so Xcode says), and a rename of the Swift files.
I delete the template entity and add two more. I modify the master and detail data access and formatting to accommodate the new entities (the entity classes were created by mogenerator, which I’d think wouldn’t matter).
The unwind segues from detail to master do not appear. They do in the template.
# What I’ve tried
This first turned up in a project I started on a very early beta of Xcode 6, but the problem persists in a minimal from-scratch rebuild.
A web search turned up little of use, with discussions begun and closed in early July. The Xcode release notes that provided the workarounds for this problem have been amended to have no reference to it (as I’d expect).
I tried the workarounds anyway. The result is that having added (then removed) the application namespace to the controller scenes, the storyboard no longer reports the root (then-top) controller as being of my subclass — it instantiates a regular UITableViewController:
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
-> Bool {
// Override point for customization after application launch.
let navigationController = self.window!.rootViewController as UINavigationController
for vc in navigationController.viewControllers {
NSLog("found \(vc.title)")
// Optional("Passers") is the only output.
// That is the title set in IB for that controller.
}
// ****** Crash ******
let controller = navigationController.topViewController! as PasserListController
// *****************
controller.managedObjectContext = self.managedObjectContext
// My own initialization:
initUtilities()
var error: NSError? = nil
return loadSampleData("sample-data", error: &error)
}
It took some lldb gymnastics to get at this — navigationController would show up in the Variables pane, but the lldb console refused to deal with it because it was undefined. (Optimization = -O0) I captured the object pointer with `expr self.window!.rootViewController as UINavigationController`. lldb reports .viewControllers! as {}, and .topViewController as UITableViewController (not PasserListController).
The declaration of the class is no different from the template:
class PasserListController: UITableViewController, NSFetchedResultsControllerDelegate {
It’s proving difficult to strip my changes down to the point where I can get back to a working app.
Poking around with the Hopper Disassembler tells me that the objc class PasserListController is present in the linked executable for the simulator. The string PasserListController appears in the text of the storyboard file, and "UITable" does not.
Thrashing, in the form of putting the `public` attribute on the class and wherever the compiler asked for it, didn’t help.
# Plea
This _looks_ like a regression, but it’s one of those “impossible, Apple would have caught it” things.
What am I doing wrong? Or if I’m not, how can I work around it?
— F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden