Daily iOS
Swift

Extensions and stored properties

You want to add a property to an existing type with an extension. Computed properties work, so why not stored properties?

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

An extension only adds code; it can't change the type's memory layout (instance size and field offsets), so stored properties are out.

Share a question