I’m working on an app for my Particle devices. I want to call a function, but I’m having a hard time wrapping my head around this code:
var myPhoton1 : ParticleDevice?
let funcArgs = ["D7", 1] as Any
var task = myPhoton1!.callFunction("digitalWrite", withArguments: funcArgs as! [Any]) { (resultCode : NSNumber?, error : Error?) -> Void in
if (error == nil) {
print("LED on D7 successfully turned on")
}
}
var bytesToReceive : Int64 = task.countOfBytesExpectedToReceive
// ..do something with bytesToReceive
My question is how do I specify the particle device that i want to call the function on? I have the app getting all of the devices and displaying on a table view with an array. Any help would be appreciated. Thank you.
PS: still learning the Swift coding environment - be gentle please…