Array from dictionary weird state

Viewed 20

I have the following dictionary created in a parent view model:

var filtersDict: [FKey: [Filter]] = [:]

init(...) {
  ...
  for key in FKey.allCases {
       filtersDict[key] = []
  }
}

I'm passing this object via dependency injection down a navigation stack. Let's call it A to B . In B, I'm adding an object like so:

self.filtersDict[FKey.categories]?.append(filter)

In B everything is fine, I can see my data. When going back to A, when reading self.filtersDict[FKey.categories] array count is 0. What am I missing here ? Shouldn't it be the same object ?

Many thanks

0 Answers
Related