protocol
protocol ControllerDelegate : NSObjectProtocol {
func Controller(Controller: obj, clickedIndex index: Int);
}
The variable for delegate
class Controller: UIView {
var delegate:ControllerDelegate!;
...
call delegate function like this
Now you donot need to point a function like @selector("function:name:")
Using respondsToSelector("function:name:") is OK
func buttonClicked(sender:UIButton) {
if self.delegate.respondsToSelector("Controller:clickedIndex:") {
delegate.Controller(self, clickedIndex:sender.tag);
}
}