Post

Replies

Boosts

Views

Activity

Reply to Mutating an array of model objects that is a child of a model object
@joadan What you're saying about an array being a value type even if it has reference types makes sense to me. What I'm a little confused about is that when I pass subcategories by reference in the sample project I have (i.e. passing it as a parameter to a struct where it's declared as var subcategories: [Subcategory], it still does update when I mutate the array using project.subcategories?.removeAll { $0 == subcategory }. Regarding what I was saying in the paragraph after the second block of code, I just meant that you can't unwrap the array like normal: if var subcategories = self.project.subcategories { subcategories.removeAll { $0 == subcategory } } and instead have to do this: if let subcategories = self.project.subcategories { self.project.subcategories?.removeAll { $0 == subcategory} } Just feels off to me.
Sep ’25