I am able to correctly select and store the tokens of apps and categories my users will block, but I am unable to pre-populate Picker whenever the app is rebooted with previously selected and stored tokens. Below is the selection variable I am passing to the picker...
var selectionsToBlock = FamilyActivitySelection() {
willSet {
saveSelection(selection: newValue)
blockersSelected = true
}
}
Is there any way I can provide my existing blockers (shown below) so that the user can easily edit their list of restricted apps from the Picker?
func savedBlockers() -> FamilyActivitySelection? {
let defaults = UserDefaults.standard
guard let data = defaults.data(forKey: userDefaultsKey) else {
return nil
}
return try? decoder.decode(
FamilyActivitySelection.self,
from: data
)
}