Showing the Header View of Your Swift Classes - Swift 2.0, Xcode 7 and Interface Builder - iOS 9 Swift Programming Cookbook (2015)

iOS 9 Swift Programming Cookbook (2015)

Chapter 1. Swift 2.0, Xcode 7 and Interface Builder

1.10 Showing the Header View of Your Swift Classes

Problem

You want to get an overview of what your Swift class’s interface looks like.

Solution

Use Xcode’s new Generated Interface Assistant Editor. This is how you do it. Open your Swift file first and then, in Xcode, use Show Assistant Editor, which you can find in the Help menu if you just type that name. After you open the assistant, you will get a split screen of your current view. Then in the second editor that opened, on top, instead of Counterparts (which is the default selection), choose Generated Interface. You’ll see your code as shown in Figure 1-4.

Figure 1-4. Code shown in Xcode assistant

Discussion

I find the Generated Interface functionality of the assistant editor quite handy if you want to get an overview of how clean your code is. It probably won’t be day-to-day functionality that you use all the time. But I cannot be sure. Maybe you will love it so much that you will dedicate a whole new monitor just to see your generated interface all the time. By the way, there is a shortcut to the assistant editor in Xcode 7: Command+Alt+Enter. To get rid of the editor, press Command+Enter.

See Also