Ryan
Ryan

Reputation: 2660

Boilerplate Code for Subclassing UIViewController in Swift

With Xcode when you create a new Objective-C file with subclass Uiviewcontroller, you get a new file with all the boilerplate code ready to be edited. When I create a new file in swift, it's completely blank. Is this by design? How do I get the same template/boilerplate code so that I can get started coding quickly?

Upvotes: 4

Views: 1101

Answers (1)

Ryan Brodie
Ryan Brodie

Reputation: 6620

  1. Instead of creating a "Swift File", choose "Cocoa Class":

    enter image description here

  2. Then choose the appropriate subclass:

    enter image description here

  3. Finally click next and save to your desired location.

N.B.

You may need to change the import statement from import Cocoa to import UIKit

Upvotes: 5

Related Questions