|
From: Yvon T. <tho...@fr...> - 2006-02-17 08:34:54
|
Le 16 f=E9vr. 06 =E0 20:35, Jonathan Paisley a =E9crit :
>
> Let me know if that works for you.
in my previous Controller.rb, i've added :
require 'OutlineViewProxyClass.rb'
include NSOutlineViewable # probably not usefull ?
i've transformed each bookmark to bookmark.slave seems to be no =20
probs here.
However for "def outlineView_child_ofItem(aTree, index, bookmark)" =20
i've done :
return @folder.to_nsobj if bookmark.class =3D=3D NilClass # case of =
root =20
element @folder being a REXML::Element
children =3D bookmark.slave.get_elements("*")
return children[index].to_nsobj
and i get an error :
/Users/yvon/work/RubyCocoa/BookmarksMerge/build/Development/=20
BookmarksMerge.app/Contents/Resources/OutlineViewProxyClass.rb:14:in =20
`NSApplicationMain': NSApplicationMain - RBException_TypeError - =20
can't convert REXML::Element into Integer (OSX::OCException)
from =
/Users/yvon/work/RubyCocoa/BookmarksMerge/build/Development/=20
BookmarksMerge.app/Contents/Resources/rb_main.rb:44
OutlineViewProxyClass.rb:14 being :
ObjectSpace._id2ref(@slave) # used to prevent GC cycle
quiet, that's the first time i'm using a proxy ;-)
then i'm not sure on how to use it ))
best,
Yvon
---------------------- OutlineViewProxyClass.rb =20
------------------------------------------------------------------
require 'rexml/document'
include REXML
# Define helper class
class OutlineViewProxy < OSX::NSObject
ns_overrides :init
def init(slave)
super_init
@slave =3D slave
self
end
def slave
ObjectSpace._id2ref(@slave) # used to prevent GC cycle
end
end
# One instance of helper class per plain ruby object being helped
module NSOutlineViewable
def to_nsobj
# This will be released with ruby instance is GC-ed
@__nsoutlineviewproxy ||=3D OutlineViewProxy.alloc.init(self)
end
end
# Include the helper module in REXML::Element
module REXML
class Element
include NSOutlineViewable
end
end
---------------------- OutlineViewProxyClass.rb =20
------------------------------------------------------------------
|