Store data in protocol and class extensions

Sayler8182
Mac O’Clock
Published in
Nov 16, 2020

--

Photo by benjamin lehman on Unsplash

Many times I needed to save some data in protocol or class extensions. By default Swift doesn’t allow us to do this, but there is simple workaround using runtime manipulation. If you try add computed property in standard way, You will probably see compile error

Extensions must not contain stored properties

--

--