如何快速从.Framework返回值到示例应用程序

时间:2019-06-25 11:49:17

标签: ios swift completionhandler

我创建了一个.Framework并包含在示例应用程序中,一切正常。我的.Framework包含2个ViewControllers.swift类。我的问题是,一旦任务完成,如何将.Framework类中的值返回给示例应用程序。任务完成后,我需要从任何.swift类文件中返回值。

以下是.Framework代码,我必须从示例应用程序中调用该代码,

 open class func getMerchantDetails(Values: Dictionary<String, Any>, VC: UIViewController ,NC: UINavigationController, completionHandler: CompletionHandler)                                                          {
    let storyboardName = "main1"
    let storyboardBundle = Bundle(for: self)
    let storyboard = UIStoryboard(name: storyboardName, bundle: storyboardBundle)

    if Values["secure"] == "secure"
    {
        let vc = storyboard.instantiateViewController(withIdentifier: "secureView") as! secureViewController
        vc.merchantDetails = merchantValues
        NC.pushViewController(vc, animated: true)

    }else
    {
        let vc = storyboard.instantiateViewController(withIdentifier: "webView") as! WebViewController
        vc.merchantDetails = merchantValues
        NC.pushViewController(vc, animated: true)
    }
}

如何从.Framework内的任何类中完成该completeHandler?

ObjectiveC

在.h文件中,我将声明以下内容

  @property(strong)myCompletion _compblk;

在.m文件中,我将获得与下面相同的引用,

-(void) callQRAPI :(UIViewController *)controller :(myCompletion)compblock
{
    __compblk = [compblock copy];
}

我将在任何地方使用__compblk对象来完成该过程。同样,我在Swift或其他任何方式中需要将.Framework中的值传递给示例应用程序。

0 个答案:

没有答案