aleclarson / emitter-kit

Type-safe event handling for Swift
MIT License
566 stars 70 forks source link

Fix the problem that can not be handling Notification #5

Closed tokorom closed 9 years ago

tokorom commented 9 years ago

Before

aleclarson commented 9 years ago

Sorry, but your change would allow a NotificationListener with no target to be triggered no matter the target. Listeners with no target have a targetID equal to an empty string. If the NSNotification.object is equal to nil, hashify will return an empty string, thus working as expected.

You need to be using the UIApplication instance as the target for things to work correctly.

let didBecomeActive = Notification(UIApplicationDidBecomeActiveNotification)
didBecomeActive.once(UIApplication.sharedApplication()) {
  println("UIApplication became active: \($0)")
}
tokorom commented 9 years ago

Thank you for reply :)

I understand it.

aleclarson commented 9 years ago

:+1: