Skip to content
Browse files

notification center helpers

  • Loading branch information...
1 parent 7d36a30 commit 33a75c9730760078816d28af30f84592f198f589 @siuying siuying committed
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/ns_notification_center.rb
View
12 lib/ns_notification_center.rb
@@ -0,0 +1,12 @@
+class NSNotificationCenter
+ def observe(key, name, object=nil, &proc)
+ @observers = {} unless @observers
+ @observers[key] = proc
+ self.addObserver(proc, selector:'call', name:name, object:object)
+ end
+
+ def unobserve(key)
+ proc = @observers[key].delete
+ self.removeObserver(proc)
+ end
+end

0 comments on commit 33a75c9

Please sign in to comment.
Something went wrong with that request. Please try again.