Adding swift file to new view controller in xCode? (easy)
Asked Answered
P

2

28

I'm just starting out in xCode 6, and I can't seem to figure out how to add a new swift-file to the new view controllers I add in the interface builder.

Any tips on how to proceed would be appreciated.

Priorate answered 16/11, 2014 at 22:18 Comment(0)
R
60
  1. Add a new Cocoa Touch class. Choose File->New->File... from the menu. Give this new class a name such as "ViewController2" and set the Subclass of: pop down to UIViewController. The file "ViewController2.swift" will be created.

enter image description here

enter image description here

  1. Click on your new View Controller in Interface Builder. In the Identity Inspector (on the right in Xcode) set the Custom Class for the View Controller to "ViewController2".enter image description here
Roomette answered 16/11, 2014 at 22:45 Comment(2)
The custom class won't show up in the Identity Inspector.Adjoin
Had to make sure the view controller button was pushed on the view in the view controller (the yellow one on the top of each view in the storyboard).Adjoin
I
0

If your custom class isn't showing up in the Identity Inspector, your files may have been moved or saved in the wrong folder. I would delete them from your project and try again, this time letting the files be saved wherever they are automatically. Good luck!

Incidentally answered 11/9, 2017 at 0:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.