Daily iOS
SwiftUI

View as a struct

UIView is a class, so why was SwiftUI's View designed as a struct?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A View is a description of how to draw state, not a screen object, so as a value type it can be created, thrown away, and compared cheaply without the burden of identity or inheritance.

Share a question