0

I have impleented SWRevealViewController for sideMenu. My project is is Swift and SWRevealViewController is in Objective-c. SWRevealViewController is not initial view Controller.there is one intial View Contoller(1VC) and it has Push segue on SWRevealViewController. another ViewController (2VC) is act as FrontView. I want to pass data from (1VC) to (2VC). but I could not find any way

enter image description here Here is My Stroyboard

Komal Kamble
  • 424
  • 1
  • 8
  • 25
  • what kind of data you want to send? – Akash KR Jun 13 '16 at 06:14
  • some String From Intial ViewController(which is before SWRevealViewController) to anotherViewController (here is DashBoard which is SWRevealViewControllerSegueSetController segue) – Komal Kamble Jun 13 '16 at 06:20
  • 1
    In this kind of situation the NSNotificationCenter is best way to complete the functionality. For more reference please see https://iosdevcenters.blogspot.com/2016/03/nsnotification-nsnotificationcenter-in.html – Chetan Prajapati Jun 13 '16 at 06:21
  • In swift everything is public, so you can define your variables outside the scope of class i.e. after import statement. – Akash KR Jun 13 '16 at 06:31

1 Answers1

0

Two ways:

In case of segue

override func prepareForSegue(segue: UIStoryboardSegue!,sender: AnyObject!){         
//make sure that the segue is going to secondViewController
if segue.destinationViewController is secondViewController{
// now set a var that points to that new viewcontroller so you can call the method correctly
let nextController = (segue.destinationViewController as! secondViewController)
nextController.setResultLabel((String(myResult)))
 }
}

Otherwise in swift everything is public by default. Define variables outside the class

import UIKit

var placesArray: NSMutableArray!

class FirstViewController: UIViewController {
//
..
//
}

and then access it

import UIKit

class SecondViewController: UIViewController {
//
placesArray = [1, 2, 3]
//

}

Akash KR
  • 778
  • 3
  • 11