Observer | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1941154-fundamental-ios-design-patterns/lessons/20

Why not just use didSet and willSet?

@jrg.developer Can you please help with this when you get a chance? Thank you - much appreciated! :]

You could accomplish a similar result by overriding these! However… :wink:

  • You’d write more code
  • You’d have to take care of one-to-many mappings yourself, including memory management (preventing strong-reference cycles, etc)
  • You’d have to worry about testing, maintaining, etc the above

When you have a first-party solution that’s provided for you already that does all of the above, why not just use it? :wink:

1 Like

Nice points there :stuck_out_tongue_winking_eye:
Adding extra characters to post comment, please ignore