Most of this code is required for Node and for execution in BlueMix. VCAP_SERVICES is the Bluemix environment variable that you use to obtain the credentials for this service that you are interested in using. In this case, the service_name parameter is set to question_and_answer to access the Q&A platform service.
In your Bluemix environment, you must have a Q & A instance and application. When an application is bound to a Q & A service, it creates a binding to the service. The service binding has application credentials for accessing the service instance. In this case, VCAP_SERVICES contains the URL, username and password of the binding used to transmit and authenticate with the service instance.
From your iOS application you will need a few things. First, you need a service binding, and for now, you need to create this in Bluemix. Once you have your credentials in Bluemix, you can use them in your iOS app. Or you can host the app on Bluemix and let it interact with Watson.
Then you need the ability to call the Question and Answer service, which is a RESTful service. In the above code, the options variable contains the necessary information for a POST question to the Watson service. Please note that the service_url obtained from the credentials is added with additional information about the path to use the Watson For Healthcare domain.
From there you can create your own question. The questionData variable contains the question in the code above. The question.questionText property has been asked a question that you want to ask Watson, for example: "Do I have to take aspirin on a daily basis?"
You can then submit the question to Watson, as the following snippet does:
watson_req.write(JSON.stringify(questionData));
Node is asynchronous, so the response is processed in http.request(...) . The response is sent back to the requesting application at
result.on('end', function() { var answers_pipeline = JSON.parse(response_string), answers = answers_pipeline[0]; return res.render('index',{'questionText': req.body.questionText, 'answers': answers}) })
The rest of the code is Node. But I outlined the basics you need in an iOS app.