0

I am going to update my customised sample based on Build a home assistant mobile application with Watson and IoT Platform services

In this code I get the message:

Can not convert value of type 'String' to expected argument type 'InputData?'

How to solve this problem? Inside the documentation of developer cloud/conversation/api I can find the definition of InputData, but NO sample how to realize this in Swift iOS?

    // Based on API Changes
    // ====================
    // Incorrect argument label in call (have 'text:context:', expected 'input:context:')
    // Cannot convert value of type 'String' to expected argument type 'InputData?'
    let request = MessageRequest(input: text, context: self.context)
    self.conversation?.message(workspaceID: Credentials.ConversationWorkspaceID,
                               request: request,
                               failure: failure) {
                                response in
                                print(response.output.text)
                                self.didReceiveConversationResponse(response.output.text)
                                self.context = response.context
                                // issue command based on intents and entities
                                // Additional Properties:
                                // response.context.json -> response.context.additionalProperties
                                print("appl_action: \(response.context.additionalProperties["appl_action"])")
                                self.issueCommand(intents: response.intents, entities: response.entities)
    }

1 Answers1

1

The input parameter of the MessageRequest constructor takes an InputData object, which is easy to construct from a text string. Try

let input = InputData(text: text)
let request = MessageRequest(input: input, context: self.context)
self.conversation?.message(workspaceID: Credentials.ConversationWorkspaceID,
                           request: request,
                           failure: failure) {
Mike Kistler
  • 437
  • 2
  • 10
  • Hello Mike, thanks but after fixing this now I have a other problem with "framework not found RestKit". Regards, Thomas – Thomas Suedbroecker Jan 16 '18 at 08:00
  • If you are using the latest release of the Watson Swift SDK, it no longer builds RestKit as a separate framework, but instead links it directly into each service. So you should be able to just remove the RestKit framework from your project. – Mike Kistler Jan 17 '18 at 15:57
  • Thanks for your feedback. I am not sure this Can you pls take a look here: https://stackoverflow.com/questions/48277430/how-is-the-restkit-related-to-the-new-watson-conversation-sdk-linker-error – Thomas Suedbroecker Jan 18 '18 at 16:47