Sha256: 5cfc75fb571096d4db27647352743b7f7fc5979836e05b9be7a8f429baa3c5cd

Contents?: true

Size: 863 Bytes

Versions: 49

Compression:

Stored size: 863 Bytes

Contents

class NSNotification

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

end


class NSString

  def post_notification(object=nil, user_info=nil)
    if user_info and not user_info.is_a? Hash
      raise TypeError("Invalid argument #{user_info.class.name} 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

49 entries across 49 versions & 1 rubygems

Version Path
sugarcube-1.4.1 lib/sugarcube-notifications/notifications.rb
sugarcube-1.4.0 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.11 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.10 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.9 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.8 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.7 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.6 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.5 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.4 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.3 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.2 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.1 lib/sugarcube-notifications/notifications.rb
sugarcube-1.3.0 lib/sugarcube-notifications/notifications.rb
sugarcube-1.1.0 lib/sugarcube-notifications/notifications.rb
sugarcube-1.0.7 lib/sugarcube-notifications/notifications.rb
sugarcube-1.0.6 lib/sugarcube-notifications/notifications.rb
sugarcube-1.0.5 lib/sugarcube-notifications/notifications.rb
sugarcube-1.0.4 lib/sugarcube-notifications/notifications.rb
sugarcube-1.0.3 lib/sugarcube-notifications/notifications.rb