Sha256: 3f2d4ef312dc6563118dda5b24d7fab60037e51cd29a678868ead10e3aaaf83b

Contents?: true

Size: 784 Bytes

Versions: 62

Compression:

Stored size: 784 Bytes

Contents

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

62 entries across 62 versions & 1 rubygems

Version Path
sugarcube-0.20.18 lib/sugarcube/notifications.rb
sugarcube-0.20.17 lib/sugarcube/notifications.rb
sugarcube-0.20.16 lib/sugarcube/notifications.rb
sugarcube-0.20.15 lib/sugarcube/notifications.rb
sugarcube-0.20.13 lib/sugarcube/notifications.rb
sugarcube-0.20.12 lib/sugarcube/notifications.rb
sugarcube-0.20.11 lib/sugarcube/notifications.rb
sugarcube-0.20.10 lib/sugarcube/notifications.rb
sugarcube-0.20.9 lib/sugarcube/notifications.rb
sugarcube-0.20.8 lib/sugarcube/notifications.rb
sugarcube-0.20.7 lib/sugarcube/notifications.rb
sugarcube-0.20.6 lib/sugarcube/notifications.rb
sugarcube-0.20.5 lib/sugarcube/notifications.rb
sugarcube-0.20.4 lib/sugarcube/notifications.rb
sugarcube-0.20.3 lib/sugarcube/notifications.rb
sugarcube-0.20.1 lib/sugarcube/notifications.rb
sugarcube-0.20.0 lib/sugarcube/notifications.rb
sugarcube-0.19.5 lib/sugarcube/notifications.rb
sugarcube-0.19.4 lib/sugarcube/notifications.rb
sugarcube-0.19.2 lib/sugarcube/notifications.rb