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
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" } }
Replies
Boosts
Views
Activity
Dec ’24
Reply to "Ready to Continue" : playground, This is something that is coming on my screen top, and my program isn't running.
I have the same issue. This is draining my battery and is super annoying, since you can't just tell Playground to automatically stop when it's done.
Replies
Boosts
Views
Activity
Nov ’24
Reply to Xcode 14.1: Account Authentication Failure
Same here. This is so frustrating I made a clean install of Xcode today...
Replies
Boosts
Views
Activity
Mar ’23
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:
Replies
Boosts
Views
Activity
Mar ’21