Sha256: e151eb02ec7be60dd21a21b3e39b213ae0f5e065b0532a9897f5035164d0dfc9

Contents?: true

Size: 848 Bytes

Versions: 54

Compression:

Stored size: 848 Bytes

Contents

class NSNotification

  def [](key)
    userInfo && userInfo[key]
  end

end


class NSString

  def post_notification(object=nil, user_info=nil)
    if user_info && ! user_info.is_a?(Hash)
      raise TypeError("Invalid argument #{user_info.class.to_s} sent to String.post_notification")
    end

    if user_info
      NSNotificationCenter.defaultCenter.postNotificationName(self, object: object, userInfo: user_info)
    else
      NSNotificationCenter.defaultCenter.postNotificationName(self, object: object)
    end
  end

  def add_observer(target, action, object=nil)
    NSNotificationCenter.defaultCenter.addObserver(target,
      selector: action,
      name: self,
      object: object)
  end

  def remove_observer(target, object=nil)
    NSNotificationCenter.defaultCenter.removeObserver(target, name: self, object: object)
  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.4 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.3 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.2 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.1 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.3.0 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.2.0 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.1.1 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.1.0 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.0.8 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.0.7 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.0.6 lib/cocoa/sugarcube-notifications/notifications.rb
sugarcube-3.0.5 lib/cocoa/sugarcube-notifications/notifications.rb