gpt4 book ai didi

Swift Bridge 和 Closure Band SDK

转载 作者:行者123 更新时间:2023-11-28 08:47:59 25 4
gpt4 key购买 nike

我在尝试编译这段代码时遇到了这个错误。有人可以帮我调试吗?:

Cannot convert value of type '(NSError!) throws -> Void' to expected argument type '((NSError!) -> Void)!'

标题:

@class MSBTile;

@protocol MSBTileManagerProtocol <NSObject>

- (void)addTile:(MSBTile *)tile completionHandler:(void(^)(NSError *error))completionHandler;

@end

View Controller :

client.tileManager.addTile(tile, completionHandler: {
(error: NSError!) -> Void in
if error == nil || MSBErrorType(rawValue: error.code) == MSBErrorType.TileAlreadyExist {
self.output("Creating page...")

...
})
} else {
self.output(error.localizedDescription)
}
})

最佳答案

我为将来遇到此问题的任何人找到了解决方法。事实证明,其中两个函数调用也是可抛出的,因此我不得不将它们包装在 try catch block 中,如下所示:

 let pageTextBlock: AnyObject
do {
pageTextBlock = try MSBPageTextBlockData(elementId: 10, text: "TextButton Sample")
}catch _ {
pageTextBlock = ""
}

let pageButtonBlock: AnyObject
do {
pageButtonBlock = try MSBPageTextButtonData(elementId: 11, text: "Press Me")
}catch _ {
pageButtonBlock = ""
}

免责声明:我对 Swift 还是个新手,所以这可能不是最好的解决方案。

关于Swift Bridge 和 Closure Band SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34804058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com