Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 将目标C RXPromise结果转换为Swift 3_Objective C_Swift3_Promise - Fatal编程技术网

Objective c 将目标C RXPromise结果转换为Swift 3

Objective c 将目标C RXPromise结果转换为Swift 3,objective-c,swift3,promise,Objective C,Swift3,Promise,下面是目标C例程。问题是如何在Swift中处理结果?签名上写着这是一个承诺。但是我需要返回的线程 -(RXPromise *) createPublicThreadWithName:(NSString *)name { 它返回一个承诺,但我需要线程。Swift中获取线程的语法是什么 更新:答复: let block = BNetworkManager.shared().a.publicThread().createPublicThread(withName: name, entity

下面是目标C例程。问题是如何在Swift中处理结果?签名上写着这是一个承诺。但是我需要返回的线程

-(RXPromise *) createPublicThreadWithName:(NSString *)name {

它返回一个承诺,但我需要线程。Swift中获取线程的语法是什么

更新:答复:

    let block = BNetworkManager.shared().a.publicThread().createPublicThread(withName: name, entityID: name, isHidden: true).thenOnMain

    _ = block!({(result: Any?) -> Any? in
        if let thread = result as! PThread? {
            let chatViewController: UIViewController? = BInterfaceManager.shared().a.chatViewController(with: thread )
            self.navigationController?.pushViewController(chatViewController!, animated: true)
        }
        MBProgressHUD.hide(for: self.view, animated: true)

        return result
    }, {(error: Error?) -> Any? in
        MBProgressHUD.hide(for: self.view, animated: true)

        return error
    })

堆栈溢出不是代码编写服务。您尝试过什么?我尝试过的所有方法都得到了这样一个变体:无法将类型为“\uu,\u->”的值转换为预期的参数类型“promise\u completionHandler\u t?”,promise\u errorHandler\u t?“aka”Optional>,Optional-Optional>“如何将结果作为数组而不是任何数组获取?”?当我尝试将其作为数组时,编译器抛出的错误为:无法转换“Array”类型的值?->任何?'to预期参数类型'promise\u completionHandler\u t?'aka'Optional>'
    let block = BNetworkManager.shared().a.publicThread().createPublicThread(withName: name, entityID: name, isHidden: true).thenOnMain

    _ = block!({(result: Any?) -> Any? in
        if let thread = result as! PThread? {
            let chatViewController: UIViewController? = BInterfaceManager.shared().a.chatViewController(with: thread )
            self.navigationController?.pushViewController(chatViewController!, animated: true)
        }
        MBProgressHUD.hide(for: self.view, animated: true)

        return result
    }, {(error: Error?) -> Any? in
        MBProgressHUD.hide(for: self.view, animated: true)

        return error
    })
    let block = BNetworkManager.shared().a.publicThread().createPublicThread(withName: name, entityID: name, isHidden: true).thenOnMain

    _ = block!({(result: Any?) -> Any? in
        if let thread = result as! PThread? {
            let chatViewController: UIViewController? = BInterfaceManager.shared().a.chatViewController(with: thread )
            self.navigationController?.pushViewController(chatViewController!, animated: true)
        }
        MBProgressHUD.hide(for: self.view, animated: true)

        return result
    }, {(error: Error?) -> Any? in
        MBProgressHUD.hide(for: self.view, animated: true)

        return error
    })