【问题标题】:Error while integrating conversation service sdk(watson-developer-cloud/swift-sdk) in Swift在 Swift 中集成对话服务 sdk(watson-developer-cloud/swift-sdk) 时出错
【发布时间】:2017-04-08 04:40:25
【问题描述】:

我已经通过在 Package.swift 中导入包为会话服务编写了 swift 代码:

let package = Package(
    name: "MySwift",
    dependencies: [
    .Package(url: "https://github.com/watson-developer-cloud/swift-sdk.git", majorVersion: 0)
])

main.swift 中的代码是:

import ConversationV1 

import Foundation

let username = "707f2a71-1fcb-4db8-a1a8-df831715d5ad"

let password = "tzQs3XMvjsOS"

let version = "2016-07-11" // use today's date for the most recent version

let conversation = Conversation(username: username, password: password, version: version)

let workspaceID = "a5d1decd-225e-4f35-b1ef-c72a672dc6a2"

let failure = { (error: Error) in print(error) }

var context: Context? // save context to continue conversation

print("calling conversation.message");

conversation.message(withWorkspace: workspaceID, failure: failure) { response in

    print("Response = \(response)")
    context = response.context
}
sleep(10)

上述应用程序从对话服务接收 json,但在解码 json 时抛出错误。 RestKit 的 JSON.swift 中抛出错误。当

"dialog_stack" =     (
        root
    );

被解码。

它期望 ("root") 但得到 (root)。 抛出的错误是:

unexpectedSubscript(Swift.String) response.result) 失败(RestKit.JSON.Error.unexpectedSubscript(Swift.String))

谁能帮助解决这个问题。谢谢!

【问题讨论】:

    标签: swift watson-conversation


    【解决方案1】:

    感谢您的反馈并在 Github 中提出问题。作为参考,这与实例化中使用的旧版本日期相关,而 SDK 跟上最新的服务实现。

    https://github.com/watson-developer-cloud/swift-sdk/issues/585

    如果您遇到更多问题,请告诉我们!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-10
      • 2020-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-28
      • 1970-01-01
      相关资源
      最近更新 更多