//
//  Stimulator.swift
//  Pods
//
//  Created by Yuki Takahashi on 2015/07/29.
//
//

import Foundation

public protocol Event {
    typealias Responder
    func stimulate(responder: Responder)
}

public extension UIResponder  {
    
    public func stimulate<E: Event>(event: E) -> E.Responder? {
        var responder : UIResponder? = self
        while (responder != nil) {
            if let responder = responder as? E.Responder {
                event.stimulate(responder)
                return responder
            }
            responder = responder?.nextResponder()
        }
        return nil
    }
    
}
//
//  Stimulator.swift
//  Pods
//
//  Created by Yuki Takahashi on 2015/07/29.
//
//

import Foundation

public protocol Event {
    typealias Responder
    func stimulate(responder: Responder)
}

public extension UIResponder  {
    
    public func stimulate<E: Event>(event: E) -> UIResponder? {
        var responder : UIResponder? = self
        while (responder != nil) {
            if let r = responder as? E.Responder {
                event.stimulate(r)
                return responder
            }
            responder = responder?.nextResponder()
        }
        return nil
    }
    
}
--- 
+++ 
@@ -15,11 +15,11 @@
 
 public extension UIResponder  {
     
-    public func stimulate<E: Event>(event: E) -> UIResponder? {
+    public func stimulate<E: Event>(event: E) -> E.Responder? {
         var responder : UIResponder? = self
         while (responder != nil) {
-            if let r = responder as? E.Responder {
-                event.stimulate(r)
+            if let responder = responder as? E.Responder {
+                event.stimulate(responder)
                 return responder
             }
             responder = responder?.nextResponder()
Change return value type UIResponder to Event.Responder
