Storyboard editor should include a dead simple "subclass" command

Originator:brent
Number:rdar://14240051 Date Originated:22-Jun-2013 07:25 PM
Status:Open Resolved:
Product:iPhone SDK Product Version:Xcode 5A11314m
Classification:New Feature Reproducible:Always
 
22-Jun-2013 07:25 PM Brent Royal-Gordon:
Summary:
After dragging out a scene/view controller, it should be extremely easy to create a subclass of whatever generic view controller is being used and automatically switch the object to that class.

Steps to Reproduce:
1. Create a storyboard-based iOS project (template doesn't really matter) and open the storyboard.
2. Drag out, say, a table view controller onto the canvas.
3. Try to turn it into a MyTableViewController with some simple functionality.

Expected Results:
There would be a button or menu item somewhere in the UI that would have something like the following workflow:
1. With a generic view controller (UIViewController, UITableViewController, UICollectionViewController, etc.) selected, click the button.
2. A sheet pops down asking for a class name and ideally nothing else. Enter the class name and click "Next".
3. Xcode adds a class by that name, which is a subclass of the class of the generic view controller selected in the storyboard, and changes the generic view controller's "Class" field to name the new subclass. It then drops you into the new class's header file, ready to write some outlets and actions to wire up.

Actual Results:
The necessary steps are:
1. Command-N for "New File".
2. Choose "Objective-C Class" and click "Next".
3. Type the name of the generic view controller class on your storyboard into the "Subclass of" field.
4. Type a name into the "Class" field. Make sure the XIB checkbox is not checked. Choose "Next".
5. Return to the storyboard.
6. Switch to the Identity Inspector tab.
7. Type your class name into the "Class" field.

Regression:
Something like the current workflow has been in place since the iOS 2.0 SDK, which is probably why it's like this.

Notes:
Almost all of the time, a generic UIViewController isn't going to be enough. Subclassing view controllers is *incredibly* common, and I really think Xcode should reflect this fact with a streamlined UI for that task. The current workflow puts you in the wrong place several times, invites you to forget crucial steps (particularly 6 and 7), requires you to remember and type class names not once, but *twice*, involves a control tucked away in an out-of-the-way inspector, gives you opportunities to do the wrong thing (like picking a different template or asking for a XIB), and in general is just much more difficult and error-prone than necessary.

This enhancement would be useful in the XIB editor as well, but putting one view controller in another view controller's XIB seems to be somewhat discouraged these days. In the storyboard editor, dragging out a view controller is basically the entire *point*.

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!