0

// I get a memory leak on this code. Any ideas? (I think it is connected to the tapRecognizer)

func paletteTapped( _ tapRecognizer : UITapGestureRecognizer )
{
    if tapRecognizer.state == .ended {
        let touch = tapRecognizer.location( in: self )
        if let color = colorForTouch(touch) {
            self.delegate?.selectPaletteColor(color)
        }
        fadeOut()
    }
}
Eran
  • 21
  • 6
  • 1
    How is `delegate` referenced? Delegates should almost always be `weak` references – Xavier Lowmiller Aug 03 '17 at 11:37
  • And don't forget to inherit your protocol from `NSObjectProtocol` or `class` , when making the reference `weak` [link for reference](https://stackoverflow.com/a/40194512/5722895) – Lausbert Aug 03 '17 at 11:44
  • weak var delegate : PaletteDelegate? and protocol PaletteDelegate : class { // delegates the selected color on a tap event func selectPaletteColor( _ color : UIColor ) } – Eran Aug 05 '17 at 19:53

0 Answers0