Closed naiyyar closed 7 years ago
@naiyyar You probably want to do this:
self.table_screen.open CommentScreen.new(blog: blog, nav: true)
Does that work?
Thank you @jamonholmgren for the help!
properties: {
screen: self
},
in custome cell
def screen=(val)
@screen = val
end
@screen.open CommentScreen
This works for me.
your one line code should work as well i'll give it a try.
Thanks
Be careful of circular references in the code you're using there. Might want to use a WeakRef:
def screen=(val)
@screen = WeakRef.new(val)
end
Ok Thanks I would prefer your way. looks easy
BTW, What is circular references and WeakRef ?
@naiyyar In RubyMotion, they use automatic reference counting for garbage collection. They keep track of which object instances have references to them (like var = MyObject.new
) and keep them alive as long as that reference is alive. When there are no more references, they garbage collect it.
The problem is if you have a circular reference, like so:
class Foo
def set(a)
@foo_ref = a
end
end
a = Foo.new
b = Foo.new
c = Foo.new
a.set(b)
b.set(c)
c.set(a)
a = nil
b = nil
c = nil
In this case, the instances a
, b
, and c
all have references to each other. So even when you unset all three variables, those @foo_ref
vars will keep the others alive forever. This results in a memory leak.
However, if you changed the internal reference to a WeakRef:
def set(a)
@foo_ref = WeakRef.new(a)
end
Then it won't count those internal references, and at the end when a
b
and c
are set to nil
, the original object instances will get garbage collected, meaning no memory leaks.
Hope this helps!
Hi,
Getting
can't convert CommentScreen into String (TypeError)
when trying to open an screen from PM::TableScreen's CustomeCellon reply button tap i'm getting this error. Is there any way to open a screen like this?
Thanks for the help!