EyeQ Tech
EyeQ Tech

Reputation: 7358

How to add the code file for a second ViewController

pardon me for beginner's question. Besides the first default ViewController with its companion file ViewController.swift, I created a 2nd viewcontroller and know how to move to it. How do I add a companion SecondViewController.swift for it?

Thanks

Upvotes: 0

Views: 3449

Answers (1)

Umair Afzal
Umair Afzal

Reputation: 5039

If you are using Xib then

1) Goto file->New->iOS->Source->Cocoa Touch Class

enter image description here

2) Select UIViewController as your Base Class and name your class and also check the checkbox with "also create Xib File" click next and click finish.

enter image description here

Now you have a new ViewController with a file associated with it.

And if you are using storyboards then follow these steps.

1) Drag and drop a viewController from object library

enter image description here

2) repeat step 1 and 2 of first method but this time do not create an Xib file

3) select your newly draged droped ViewController and assign it the new class as follows

enter image description here Now you have a new ViewController with an associated swift file.

Upvotes: 5

Related Questions