0

У меня есть реализованный SWRevealViewController для sideMenu. Мой проект - Swift, а SWRevealViewController - в Objective-c. SWRevealViewController не является начальным представлением Controller.there один intial View Contoller (1VC), и он имеет Push Segue на SWRevealViewController. другой ViewController (2VC) действует как FrontView. Я хочу передать данные от (1VC) до (2VC). но я не мог найти способКак отправить данные из одного ViewController в другой, у которого есть SWRevealViewController

enter image description here Here is My Stroyboard

+0

какие данные вы хотите отправить? –

+0

Некоторая строка из Intial ViewController (которая находится перед SWRevealViewController) в anotherViewController (здесь DashBoard, которая является SWRevealViewControllerSegueSetController segue) –

+1

В такой ситуации NSNotificationCenter - лучший способ завершить работу. Для получения дополнительной информации см. Https://iosdevcenters.blogspot.com/2016/03/nsnotification-nsnotificationcenter-in.html –

ответ

0

двумя способами:

В случае 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))) 
} 
} 

В противном случае в скор все общественное по умолчанию. Определение переменных вне класса

import UIKit 

var placesArray: NSMutableArray! 

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

, а затем получить доступ к этому

import UIKit 

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

}

+0

Thx, это работает –

+0

Удовольствие все мое –

 Смежные вопросы

  • Нет связанных вопросов^_^