Hi, I've implemented a simple solution to the retain cycle problem described in #12. Please tell if that works for you.
CADisplayLink retains the object set as its target and TOMSMorphingLabel references the display link strongly. This gives a strong reference cycle and TOMSMorphingLabel is never deallocated. This PR adds a helper class named TOMSMorphingLabelWeakWrapper which holds a weak reference to the label and forwards necessary messages to it. This breaks the reference cycle and allows deallocating the label.
Note that if the weak wrapper's label reference gets nullified due to the label being deallocated, the display link would continue firing its events to the weak wrapper. So it is necessary to properly invalidate the display link in the TOMSMorphingLabel's dealloc.
Hi, I've implemented a simple solution to the retain cycle problem described in #12. Please tell if that works for you.
CADisplayLink
retains the object set as its target andTOMSMorphingLabel
references the display link strongly. This gives a strong reference cycle andTOMSMorphingLabel
is never deallocated. This PR adds a helper class namedTOMSMorphingLabelWeakWrapper
which holds a weak reference to the label and forwards necessary messages to it. This breaks the reference cycle and allows deallocating the label.Note that if the weak wrapper's label reference gets nullified due to the label being deallocated, the display link would continue firing its events to the weak wrapper. So it is necessary to properly invalidate the display link in the
TOMSMorphingLabel
's dealloc.