[swift-users] Dealing with loss of observers on protocol properties with default implementations

Tino Heth 2th at gmx.de
Wed Nov 30 14:51:38 CST 2016


> I find this to be an ugly solution. Particularly so since non-objc protocols don't support optional members. Compare this to using a base class:

If inheritance works well, I wouldn't insist on protocols just for the sake of it.
This wont help with structs, but your example uses a class… and if you can't use inheritance for other reasons, you could try composition instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161130/e98640fd/attachment.html>


More information about the swift-users mailing list