Szymon Mrozek Szymon Mrozek - 1 year ago 130
iOS Question

Pass data to rear view using SWrevealviewcontroller

I need to pass front ViewController to rear ViewController using SWRevealViewController, but I completely don't know how to do it.

The variable in rear view looks like this:

var mainView : ViewController!

Any suggestions how to pass into it front ViewController?

Answer Source

Well it was a good question. Finally after a lot of effort I found a way out for you.

In your viewController.swift file,

import UIKit

//Add this line before your class definition
var homeController: ViewController!

class ViewController: UIViewController {

    override func viewDidLoad() {
        home = self


In your rear view controller, you can access the members of the front View Controller.

Hope this helps :-)