Skip to content

Instantly share code, notes, and snippets.

@ramiresnas
Created February 25, 2019 14:01
Show Gist options
  • Save ramiresnas/758a46a6f58f65349872ce62090f90e7 to your computer and use it in GitHub Desktop.
Save ramiresnas/758a46a6f58f65349872ce62090f90e7 to your computer and use it in GitHub Desktop.
Comunicação com GameController
override func viewDidLoad() {
super.viewDidLoad()
let center = NotificationCenter.default
let notification: NSNotification.Name = Notification.Name.GCControllerDidConnect
let selector = #selector(didConnection)
center.addObserver(self, selector: selector, name: notification, object: nil)
}
@objc func didConnection(){
guard let controller = GCController.controllers().first else {
print("algo deu errado")
return
}
print(controller.vendorName ?? "sem nome de fornecedor")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment