Post

Replies

Boosts

Views

Activity

Reply to Type Eraser for Container
I’m referring to the injection of a model container into the environment. We accomplish this by declaring the type as follows: .modelContainer(for: [Book.self, Author.self]) For instance: struct Example: App { @State private var appData = ApplicationData.shared var body: some Scene { WindowGroup { ContentView() .environment(appData) .modelContainer(for: [Book.self, Author.self]) } } } I was wondering if we could implement a feature similar to the navigationPath() type-erasing functionality. This allows us to define a heterogeneous set of types, as we can do with: @State private var path = NavigationPath() Instead of explicitly declaring: @State private var path = [Book] () Is there a way to build ( if not already a way) into Swift Language a similar capability for environment injection, enabling the injection of a heterogeneous set of types without needing to declare the type explicitly?
1w
Reply to SwiftData know how specific information
Apparently it also deletes automatically as per this : for index in indexSet { let animalToDelete = animals[index] if navigationContext.selectedAnimal?.persistentModelID == animalToDelete.persistentModelID { navigationContext.selectedAnimal = nil } modelContext.delete(animalToDelete) } } The sample above uses the SwiftData autosave feature, which is enabled by default when creating a ModelContainerusing the modelContainer(for:inMemory:isAutosaveEnabled:isUndoEnabled:onSetup:) modifier. If this feature is disabled, the removeAnimals method needs to explicitly save the change by calling the ModelContext method save(); for example: do { for index in indexSet { let animalToDelete = animals[index] if navigationContext.selectedAnimal?.persistentModelID == animalToDelete.persistentModelID { navigationContext.selectedAnimal = nil } modelContext.delete(animalToDelete) } try modelContext.save() } catch { // Handle error. } } https://developer.apple.com/documentation/swiftdata/deleting-persistent-data-from-your-app
1w
Reply to App is on App Store but Subscription is in review
My App is approved and in App Store. I have never changed anything on Subscriptions. Perhaps I shall have and a blank or a dot and resubmit ? Now subscription wasn't approved - rejected due to localisation. Message says : We have returned your in-app purchase products to you as the required binary was not submitted. When you are ready to submit the binary, please resubmit the in-app purchase products with the binary.
1w