In addition to the Apple guidelines, we generally prefer to use struct
for:
- Value types like the Networking Models
- Stateless helpers
But consider using class
instead if:
- You need to manage mutable states. Especially if there are more than a few
mutating
functions, thestruct
becomes harder to reason about. - You have to set a
struct
property declaration asvar
because it has amutating
function. In this case, a constant (let
)class
property may be easier to reason about.