как вытолкнуть контроллер быстрого просмотра из класса target-c, передать данные обратно и продолжить следующий процесс в классе target c - PullRequest
0 голосов
/ 29 сентября 2019

Я хочу отправить swift UIViewController из моего целевого контроллера и ждать, пока этот контроллер просмотра вернет данные.Как я могу это сделать.

Я попытался использовать протокол / делегат в swift, но он выдает ошибку, поскольку он недоступен в файле objc .h, даже если я импортирую заголовочный файл "Pass-swift.h"..

Мне любопытно, можно ли там делать блоки завершения, если да, то как?или любой другой подход?

//Parentviewcontroller.m file


- (void)sendNextbutton:(id)sender{

UIViewController *vc = [[SecurityQuestionViewController alloc] init];

[self.navigationController pushViewController:vc animated:YES];

// I want below signup  function to calll after getting data back from vc viewcontoller
[self singupWithSecurityQuestion];}

// .h файл

#import  "PassSDK-Swift.h"


@interface ParentViewController : UIViewController <MyProtocol>

@end

// SecurityQuestionViewController.swift

 @objc protocol MyProtocol {
   func setResultofSecurityQuestion(valueSent: [NSDictionary])
 }

@objc public class SecurityQuestionViewController: UIViewController
{    
  var delegate: MyProtocol?

@objc func didTapSubmitButton(sender: UIButton){
    let data: [NSDictionary] = getQuesDictionary()
    print(data)
    delegate?.setResultofSecurityQuestion(valueSent: data)
    navigationController?.popViewController(animated: true)
    dismiss(animated: true, completion: nil)
  }

}

// Я должен получить данные обратноParentViewController и он должен ждать, пока контроллер быстрого просмотра не отправит обратно данные, а затем он должен перейти к следующей функции / методу - singupWithSecurityQuestion.

...