Debugging events in Swift
Now, we will take advantage of Xcode's debugging features to understand how methods are called when events occur.
Leave the application running on the simulator or the iOS device.
Open the source code for ViewController.swift
.
Click on the left margin of the following line of code to establish a breakpoint at the first line of code in the mqtt
method with didReceiveMessage
as the external name of the second argument:
   print("Message received in topic (message.topic) with payload    (message.string!)")
Now, go to the iOS app and click or tap on the switch to turn on the motor again. After you change the value for the switch, the Node.js script will send a message with the new status for the motor and the mqtt
method with didReceiveMessage
as the external name of the second argument will be called. The Xcode debugger will hit the breakpoint we have set. The following screenshot shows the debugger hitting the breakpoint:
You can use all the features included in the...