Last active
August 29, 2015 14:25
-
-
Save akramhussein/d989dede3f4dc27d263a to your computer and use it in GitHub Desktop.
Handle Access Switch devices in iOS - Swift
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
var commands = [UIKeyCommand]() | |
var onceToken : dispatch_once_t = 0 | |
override var keyCommands : [AnyObject]? { | |
get { | |
dispatch_once(&onceToken) { | |
self.commands = [ | |
UIKeyCommand(input: " ", modifierFlags: nil, action: "spacePressed:"), | |
UIKeyCommand(input: "\r", modifierFlags: nil, action: "enterPressed:"), | |
UIKeyCommand(input: "0", modifierFlags: nil, action: "zeroPressed:"), | |
] | |
} | |
return self.commands | |
} | |
} | |
func spacePressed(command: UIKeyCommand) | |
{ | |
println("Access Switch Space pressed") | |
} | |
func enterPressed(command: UIKeyCommand) | |
{ | |
println("Access Switch Enter pressed") | |
} | |
func zeroPressed(command: UIKeyCommand) | |
{ | |
println("Access Switch Zero pressed") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment