user619804 user619804 - 9 months ago 59
Swift Question

Create new cocoa touch class missing in XCode7

In previous versions of XCode you could do New>File>Cocoa Touch Template to create a subclass of UIViewController with the proper imports, viewDidLoad() method and so forth. This seems to be missing from XCode7. When I do New>File, Cocoa Touch Template is missing. I can create a new Cocoa class, but this does not subclass UIViewTemplate. Is there any way to create a view controller class quickly in XCode7?

  1. Open Xcode

  2. Go to File -> New -> File

  3. Under the iOS section, select Cocoa Touch Class. Click next

  4. For the section that says Subclass of: type in UIViewController. For the section that says Class: type in the name of your subclass.

  5. Click next and save the file in the default folder.

If Xcode is not showing Cocoa Touch Class and showing Cocoa Touch instead, tap on the iOS section again and Cocoa Touch Class should appear.