【发布时间】: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))
谁能帮助解决这个问题。谢谢!
【问题讨论】: