[MacRuby-devel] NSPasteboard instance missing methods?

Laurent Sansonetti lsansonetti at apple.com
Sat Apr 24 13:45:26 PDT 2010


By default #methods and friends do not return Objective-C selectors (especially since a lot of ruby libraries are using this and cannot handle objc-style selectors), but you can get them by passing the second argument as true.

$ /usr/local/bin/macirb
irb(main):001:0> framework 'Cocoa'
=> true
irb(main):002:0> NSTableView.new.methods
=> [:load_bridge_support_file, :Complex, :Rational, :enum_for, :to_enum, :object_id, :__id__, :define_singleton_method, :public_method, :method, :extend, :respond_to_missing?, :respond_to?, :public_send, :send, :__send__, :instance_exec, :instance_eval, :__callee__, :__method__, :tap, :is_a?, :kind_of?, :instance_of?, :instance_variable_defined?, :instance_variable_set, :instance_variable_get, :instance_variables, :public_methods, :private_methods, :protected_methods, :singleton_methods, :methods, :inspect, :to_s, :untrusted?, :untrust, :trust, :frozen?, :freeze, :untaint, :tainted?, :taint, :__type__, :dup, :clone, :eql?, :!~, :=~, :===, :nil?, :!=, :!, :equal?, :==]
irb(main):003:0> NSTableView.new.methods(true,true)
=> [:"validateProposedFirstResponder:forEvent:", :controlTextDidEndEditing, :_shouldSetObjectValueOnCellsForAnimations, :"moveRowsInRange:toIndex:", :"prepareDraggingDestinationView:forRowIndexes:draggingStyle:", :cacheReusableView, :addDropBetweenFeedbackViewsForRow, :defaultOwner, :"associateView:withColumn:", :rowData, :_nextGroupRowFromRow, :"_shouldFloatRow:inVisibleRange:", :"_delegate_viewForTableColumn:row:", :_delegateRowViewForRow, :addDropOnFeedbackViewsForRow, :"_backgroundImageForRow:withFrame:", :shouldUseViews, :_validateHitTest, :setDraggedColumnView, :_isInDesignMode, :addDropFeedbackViews, :removeDropFeedbackViewsFromOldRow, :archivedReusableViews, :_headerViewDraggedDistance, :draggedColumnView, :"_updateCellInView:atRow:column:", :makeRowViewForRow, :isDropTargetRow, :"makeViewForTableColumn:row:", :isViewBased, :_needsBackgroundToAnimate, :_backgroundImageWithFrame, :_needsBackgroundImageForAnimation, :_mutableSelectedRows, :_adjustFieldEditorAnimated, :_setTrackingAreasDirty, :hiddenRowIndexes, :"_addDraggingDestinationViewForRowIndexes:draggingStyle:", :_rowForView, :_showContextualMenuForEvent, :_shouldShowContextMenuForEvent, :_rowViewDrawsHorizontalGrid, ........]

Laurent

On Apr 24, 2010, at 1:42 PM, robert gleeson wrote:

> Laurent,
> 
> Thanks! It works - I'm not sure what I did wrong, though. Maybe a typo? :-X
> By the way, is it possible to see what Objective-C methods an object can respond to?
> 
> NSObject/Object#methods doesn't seem to list them on my side?
> 
> Thanks,
> Rob
> 
> On 24 Apr 2010, at 21:34, Laurent Sansonetti wrote:
> 
>> Hi Robert,
>> 
>> At a glance it seems to be callable:
>> 
>> $ ./miniruby -e "framework 'Cocoa'; pb = NSPasteboard.generalPasteboard; p pb.canReadObjectForClasses([], options: [])"
>> false
>> 
>> Are you sure you're forming the selector correctly? The selector seems to be canReadObjectForClasses:options:.
>> 
>> Laurent
>> 
>> On Apr 24, 2010, at 9:10 AM, robert gleeson wrote:
>> 
>>> Hey,
>>> 
>>> I'm fooling around with NSPasteboard - following the documentation found at:
>>> 
>>> http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/PasteboardGuide106/Articles/pbGettingStarted.html#//apple_ref/doc/uid/TP40008150-SW1
>>> 
>>> I've got an instance of NSPasteboard through:
>>> 
>>> "board = NSPasteboard.generalPasteboard"
>>> 
>>> but "board" doesn't respond to any methods mentioned later in the tutorial I posted.
>>> 
>>> I'm looking for the method: 
>>> "canReadObjectForClasses" 
>>> 
>>> So I can continue on.
>>> 
>>> Thanks ahead of time,
>>> Rob
>>> _______________________________________________
>>> MacRuby-devel mailing list
>>> MacRuby-devel at lists.macosforge.org
>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>> 
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100424/cca19561/attachment.html>


More information about the MacRuby-devel mailing list