我正在尝试将 Zopim 中的 iOS SDK 配置到我的代码中。我的 iOS 代码是用 Swift 编写的,我导入了用 Obj C 编写的 SDK 框架。我创建了一个桥接 header ,并且能够从框架导入。
为了能够配置并连接 Zopim,我需要在 Appdelegate.swift 文件中包含以下代码。
对象 C 代码:
[ZDCChat configure:^(ZDCConfig *defaults) { defaults.accountKey = @"you account key here"; }];
我尝试将上述代码转换为 Swift(下面的代码),但出现以下错误 - 无法使用 ZDCConfig 类型的参数列表调用配置
Swift 代码:
ZDCChat.configure({(defaults: ZDCConfig) in defaults.accountKey = "you account key here"})
ZDCConfig 代码包括以下内容:
@interface ZDCConfig : ZDCSessionConfig
/** * The Zopim account key (must be set before a chat can be started). */
ZDCChat 代码包括以下内容:
** * The core of the Chat SDK, all objects related to chat can be accessed * from here either directly or indirectly. */ @interface ZDCChat : NSObject
/** * The chat session. */
任何人都可以指导我找出导致问题的原因吗?
最佳答案
我必须添加一个包含这两行的桥接头 -
#import <ZDCChat/ZDCChat.h>
#import <MobileCoreServices/MobileCoreServices.h>
然后我就可以像这样调用电话了 -
ZDCChat.configure {
defaults in
defaults.accountKey = ""
}
希望这有帮助。
关于ios - 无法调用参数列表类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32549779/