Wrapping a WeakRef with another should work like you expect it to, i.e.
class A
weak_attr_accessor :w
end
class B
weak_attr_accessor :w
end
o = NSObject.new
a = A.new
b = B.new
a.w = o
b.w = a.w
Do you have a short example where it wouldn't work correctly?
You can test for a WeakRef by doing:
a.respond_to? 'weakref_alive?'
Did you crash with a "WeakRef::RefError', reason: 'Invalid Reference - probably recycled (WeakRef::RefError)" message? WeakRef in RubyMotion (as well as Ruby) behaves different from a weak reference in Objective C. Zero-ed weak references raises an exception. I noticed that this behavoir is more desirable in my code — since RubyMotion works with iOS — I'm wondering if I should add a check to make it behave similarly.. Thoughts?