AG1
AG1

Reputation: 6774

What is the correct way to use SWRevealViewController and Swift?

What is the right way to use SWRevealViewController with Swift? XCode: 6.0.1 I am even having trouble important the file properly :/

enter image description here

MenuViewController.swift

import UIKit
import SWRevealViewController

class MenuViewController: SWRevealViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

If someone has a small github they could point me to I would really appreciate it!

Upvotes: 3

Views: 3294

Answers (2)

Omkar Guhilot
Omkar Guhilot

Reputation: 1698

You will have to create a Bridging header file to access all the objective C files in swift. Once you have created the Bridging header, all your import statements would be written inside the bridging header as

import "SWRevealViewController.h"

You don't have to write the import statements individually in each file as you used to write in Objective C. Once you include the #import statement in the Bridging-Header file, you will be able it in the entire project.

Upvotes: -1

Lance
Lance

Reputation: 9012

In order to access your Objective C classes from your Swift code, you'll need a bridging header. Apple has a good explanation here:

Swift and Objective-C in the Same Project

Once you have the bridging header:

  1. add #import "SWRevealViewController.h" to the bridging header file
  2. there is no step 2, your class is now available to all your swift code in that target.
  3. profit?

Upvotes: 6

Related Questions