ios - 无法调用参数列表类型

标签 ios objective-c xcode swift

我正在尝试将 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/

相关文章:

ios - WKWebView 中的奇怪边距

objective-c - 更改 UINavigationController View 和按钮(例如返回)中按钮的颜色?

C# 和 HTML 敏捷包 - 返回空值

ios - 使用 QuickTime Player 在 mac mini 上录制 iOS 设备屏幕(注释 : My desktop doesn't have a camera)

c# - 新 iPhone 开发者的 MonoTouch 与 Objective-C

objective-c - NSValueTransformer 没有被调用

ios - 删除 NSString 中所有出现的地方

ios - 在默认的 MonoTouch 应用程序中,xib 未在 Xcode 中打开

android - MobileFirst 应用程序在设备锁定时运行?

ios - 使iOS App具有与Excel Sheet相同的功能