[试图从快速代码中获取完成块,但看起来我做错了。
我想为我的快速视图控制器BMPSSecurityQuestionViewController
复制的我的objC代码
我只需要在完成块中返回Bool
和BMError
正常工作的代码:
BMPSAccountManagementViewController *changeVC = [[BMPSAccountManagementViewController alloc] initWithFormlyData:formlyJSON afterUpdatingProfile:completion];
@implementation BMPSAccountManagementViewController
- (instancetype)initWithFormlyData:(NSDictionary *)json afterUpdatingProfile:(void (^)(BOOL, BMErrors *))completion {
self = [super initWithFormlyData:json];
if (self) {
self.updateCompletion = completion;
}
return self;
}
我做错的代码:
changeVC.changeSecurityQuestionDelegate = [[BMPSUpdateSecurityQuestionViewModel alloc] init completionData:completion];
我尝试像objc函数一样复制的快速代码:
@objc public class BMPSSecurityQuestionViewController {
var completionData: ((Bool, BMErrors?) -> Void)?
public required init?(coder aDecoder: NSCoder) {
fatalError("Not implemented")
}
@objc public init(completionData completion: ((Bool, BMErrors?) -> Void)?) {
super.init(nibName: nil, bundle: nil)
self.completionData = completion
}
public func verifySuccess() {
//self.completionData
// here I want to set completion data but I don't know how to do it
}
}
您可以使用以下代码初始化BMPSSecurityQuestionViewController.completionData
:
self.completionData = { boolValue, errors in
//This is how you can use boolValue and errors
if boolValue {
if let errors = errors {
}
}
}