Closed hboon closed 10 years ago
Sweet - is it possible to add a test for this/the two instances where weak!
is called?
First-timer with spec, would be safe if someone help reviews the test code. Also duplicated the test case across 2 files, not sure the alternative of extracting them out is good.
Looks good, but did you mean to use when_tapped
instead of subject.when(UIControlEventTouchUpInside)
in ui_view_wrapper_spec.rb
?
Pardon my ignorance, but why is this setting necessary? Aren't blocks that create retain cycles bugs?
UIControl#when
and friends all hold a strong reference to a block callback. So when would a view controller, a view, or any other object, want this block -- defined in its scope -- to hold a strong reference to itself?
EDIT: Forgot to explicitly refer to a BW callback.
It's a bug, but I suppose some people might have inevitably relied on the strong reference. So it'd be nice to keep the behaviour, preserve compatibility and let people switch manually for the time being.
I defer to Clay here: https://github.com/rubymotion/BubbleWrap/issues/322#issuecomment-30558903
Saw the test was fixed, thanks @hboon!
When set to true, #weak! will be used for UIControlWrapper.
Also: https://github.com/rubymotion/BubbleWrap/issues/322#issuecomment-30558903.
Added #use_weak_callbacks to shortcut.rb, seeing that #debug is there. Is it the correct place?