Я хочу отправить быстрый UIViewController из моего целевого C 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.
@objc
везде: передfunc
, передvar delegate
— посмотрите, поможет ли это. - person Yonat   schedule 29.09.2019