Struct and class

Struct. For most purposes you want structs, classes mainly exist for compatibility with Objective C. classes are also useful if you want to implement copy-on-write things. However 98% of the time you want a struct.

Classes have a bad rep in Swift for being slow (though people are working on improving this) but their main issue is that they have reference semantics, and Swift is a language that’s really oriented towards value semantics. This can make code that uses a lot of classes confusing and hard to understand.

see this thread for more

3 Likes