Frederic
Frederic

Reputation: 497

Creating a class for a new view controller

My Xcode project came with a default:

class ViewController: UIViewController

I then created a new view controller with the id next.

How can I create a class like the one the project had already created, but for my view controller next?

I thought it would look something like:

class next: UIviewcontroller

Upvotes: 0

Views: 52

Answers (1)

Alexey Pichukov
Alexey Pichukov

Reputation: 3405

If I understand what you want to do, then you need to create a class NextViewController and override methods viewDidLoad and didReceiveMemoryWarning like this:

class NextViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

And then at your storyboard in Identity inspector tab select the created class for your ViewController like this:

enter image description here

Upvotes: 1

Related Questions