Boiler code for subclassing UIViewController in Swift

With Xcode, when you create a new Objective-C file with a Uiviewcontroller subclass, you will get a new file with all the template ready to edit. When I create a new file in swift, it is completely empty. Is it by design? How do I get the same template / boilerplate code so I can start coding quickly?

+3


source to share


1 answer


  • Instead of creating a "Swift File" select "Cocoa Class":

    enter image description here

  • Then select the appropriate subclass:

    enter image description here

  • Finally, click "Next" and save to the desired location.

NB



You may need to change the import statement from import Cocoa

toimport UIKit

+4


source







All Articles