Hoping someone can lead me to finding a solution on passing a variable to another view controller.
Here is the situation:
I have “log in” and “get device” in my first view controller. No problem with logging in and accessing my device from the cloud. I also have a button that takes me to my second view controller with no issues. There are six switches designed to turn relays on and off in the second controller. I also understand how to program the switches.
I’m assuming I need to create another instance of “device” in the second controller to call functions. I already successfully designed the firmware housing the functions I need to call, and they successfully compiled and flashed my device.
I believe I need to use the prepare for Segue function in the primary controller and design a variable in the second controller to house what I pass from the primary controller. That said, I don’t know what “type” the variable should be. I named the variable myPhoton2 in the second controller.
You probably shouldn’t be creating another instance of your device in the second controller. If you only have one device, you should only have one instance. You should pass a reference that points to your photon in the first controller to the second one. Something like,
secondviewController.myPhoton2 = myPhoton1
The type of myPhoton2 would be the same as what myPhoton1 is.
I’m not sure, since I use my own iOS code, and not any of the classes in The Particle app. You must already have a type for self.device though, right? How is ‘device’ declared?