Last active
June 19, 2018 08:49
-
-
Save litoarias/0e6438e97213174bb456addce7c59bf8 to your computer and use it in GitHub Desktop.
Watch Tutorial 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
// 1: Get singleton class whitch manage WCSession | |
var connectivityHandler = SessionHandler.shared | |
// 2: Counter for manage number of messages sended | |
var messagesCounter = 0 | |
// ... | |
/// Send messages on main thread | |
@IBAction func sendMessage(_ sender: UIButton) { | |
messagesCounter += 1 | |
// 3: Send message to apple watch, we don't wait to response, only trace errors | |
connectivityHandler.session.sendMessage(["msg" : "Message \(messagesCounter)"], replyHandler: nil) { (error) in | |
print("Error sending message: \(error)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment