def apply(method_name, *args, &block)
      method_name = method_name.to_s
      raise ApplyError.new("Cannot apply #{method_name.inspect} to instance of #{target.class.name}") if method_name.length == 0

      # if there is no target, than we should raise the NoMethodError; someone
      # called a method on the layout directly.
      begin
        target = self.target
      rescue NoContextError => e
        raise NoMethodError.new("undefined method `#{method_name}' for #{self}:#{self.class}", method_name)
      end

      objc_method_name, objc_method_args = objc_version(method_name, args)
      ruby_method_name, ruby_method_args = ruby_version(method_name, args)

      @layout_delegate ||= Layout.layout_for(target.class)
      if @layout_delegate
        @layout_delegate.set_parent_layout(parent_layout)
        if objc_method_name && @layout_delegate.respond_to?(objc_method_name)
          return @layout_delegate.send(objc_method_name, *objc_method_args, &block)
        elsif @layout_delegate.respond_to?(ruby_method_name)
          return @layout_delegate.send(ruby_method_name, *ruby_method_args, &block)
        end
      end

      if block
        apply_with_context(method_name, *args, &block)
      else
        apply_with_target(method_name, *args, &block)
      end
    end
def apply(method_name, *args, &block)
      method_name = method_name.to_s
      raise ApplyError.new("Cannot apply #{method_name.inspect} to instance of #{target.class.name}") if method_name.length == 0

      # if there is no target, than we should raise the NoMethodError; someone
      # called a method on the layout directly.
      begin
        target = self.target
      rescue NoContextError => e
        raise NoMethodError.new("undefined method `#{method_name}' for #{self}:#{self.class}", method_name)
      end

      objc_method_name, objc_method_args = objc_version(method_name, args)
      ruby_method_name, ruby_method_args = ruby_version(method_name, args)

      @layout_delegate ||= Layout.layout_for(target.class)
      if @layout_delegate
        @layout_delegate.set_parent_layout(parent_layout)
        if objc_method_name && @layout_delegate.respond_to?(objc_method_name)
          return @layout_delegate.send(objc_method_name, *objc_method_args, &block)
        elsif @layout_delegate.respond_to?(ruby_method_name)
          return @layout_delegate.send(ruby_method_name, *ruby_method_args, &block)
        end
      end

      if block
        apply_with_context(method_name, *args, &block)
      else
        apply_with_target(method_name, *args, &block)
      end
    end
Tries to call the setter (`foo 'value'` => `view.setFoo('value')`), or
 assignment method (`foo 'value'` => `view.foo = 'value'`), or if a block
 is given, then the object returned by 'method_name' is assigned as the new
 context, and the block is executed.

 You can call this method directly, but usually it is called via
 method_missing.