Post

Replies

Boosts

Views

Activity

Reply to I wonder swiftdata query cannot be used within a class
// ContentView.swift import SwiftUI import SwiftData @Model class TrackedItem { @Attribute var name: String init(name: String) { self.name = name } } struct ContentView: View { @Query private var items: [TrackedItem] @StateObject var viewModel = ViewModel(items: []) var body: some View { NavigationStack { YourAppView() } .environmentObject(viewModel) .onAppear { viewModel.reloadData(items: items) } .onChange(of: items) { viewModel.reloadData(items: items) } } } // ViewModel.swift import Foundation class ViewModel: ObservableObject { @Published var stuff: String = "Stuff" var items: [TrackedItem] init(items: [TrackedItem]) { self.items = items fetchData() } func reloadData(items: [TrackedItem]) { self.items = items fetchData() } private func fetchData() { stuff = "New stuff" } }
Dec ’24
Reply to Localstorage in ios13 resetting by itself
Your problem may be linked to the 7 days cap on localStorage introduced in iOS/iPad 13.4 Here is a link to a blog post from webkit : Full Third-Party Cookie Blocking and More - https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/ Did you try using service workers ? I wonder if service workers could prevent data loss in PWA Hope I helped.
Topic: Safari & Web SubTopic: General Tags:
Mar ’21