Good morning. Following the development of an app connected to a relay board through the network I have encountered a problem.
I have a board connected to a network with an ip: 192.168.0.190
to activate or deactivate the relays simply I have to call with the browser to link to activate the 1 or link to turn it off
Well, I have done it through this method and I would like you to tell me if simply to make that call (you do not have to execute or process any HTML) could be done more easily, or if this is correct at least:
func realizoConexion(cadena:String){
let ip=UserDefaults.standard.string(forKey: "ipplaca")
var cadenaFinal:String="http://"+ip!+cadena
print(cadenaFinal)
var request=NSMutableURLRequest(url:NSURL(string: cadenaFinal)! as URL)
var session=URLSession.shared
request.httpMethod="POST"
var task=session.dataTask(with: NSURL(string: cadenaFinal)! as URL)
task.resume()
}