我正在实现一个 NSControlTextEditingDelegate 协议,但我不知道我应该与哪个类/协议匹配,例如 commandSelector。#selector(WhichClass.moveUp(_:)) 以便相等通过。
目前 swift 2.1 一切正常:
func control(control: NSControl, textView: NSTextView, doCommandBySelector commandSelector: Selector) -> Bool {
var goUp = false
var goDown = false
if (commandSelector == Selector("moveUp:") ||
commandSelector == Selector("moveBackward:") ||
commandSelector == Selector("moveUpAndModifySelection:") ||
commandSelector == Selector("moveParagraphBackwardAndModifySelection:")
)
{
goUp = true
}
if (commandSelector == Selector("moveDown:") ||
commandSelector == Selector("moveForward:") ||
commandSelector == Selector("moveDownAndModifySelection:") ||
commandSelector == Selector("moveParagraphForwardAndModifySelection:")
) {
goDown = true
}
//...
}