Post

Replies

Boosts

Views

Activity

Reply to SwiftData Update Item View from Background Thread
Found this thread wile trying to solve a similar problem, and silence all the errors from console. This isn't an elegant solution, and may not apply directly but it is what worked for me so I wanted to share – to get updates in a view. Instead of "updating" the context I delete the existing and then re-add it. @MainActor func load_video_in_background(context: ModelContext) async throws { let existing = try context.fetch(FetchDescriptor<Video>( predicate: #Predicate { $0.id == content_id } )).first // async fetch from db here to get fresh data // ... // transform fetched data to class & validate // ... if let existing = existing { context.delete(existing) } context.insert(content) } Then in my view I pass the context into this function @Environment(\.modelContext) private var context // view logic // ... .task { do { try await load_video_in_background(context: context) } } So far I haven't had any problems with the above, obviously make sure you are relying on @Query and instead of @Binding or @State to show your data.
Mar ’25
Reply to SwiftData Update Item View from Background Thread
Found this thread wile trying to solve a similar problem, and silence all the errors from console. This isn't an elegant solution, and may not apply directly but it is what worked for me so I wanted to share – to get updates in a view. Instead of "updating" the context I delete the existing and then re-add it. @MainActor func load_video_in_background(context: ModelContext) async throws { let existing = try context.fetch(FetchDescriptor<Video>( predicate: #Predicate { $0.id == content_id } )).first // async fetch from db here to get fresh data // ... // transform fetched data to class & validate // ... if let existing = existing { context.delete(existing) } context.insert(content) } Then in my view I pass the context into this function @Environment(\.modelContext) private var context // view logic // ... .task { do { try await load_video_in_background(context: context) } } So far I haven't had any problems with the above, obviously make sure you are relying on @Query and instead of @Binding or @State to show your data.
Replies
Boosts
Views
Activity
Mar ’25
Reply to iOS 18 - Webcam video not rendered within page without interacting with browser chrome
Did you find any workarounds for this? I am facing the same issue, in iOS 18 safari almost immediately ends a MediaStreamTrack giving me a blank video, the moment it is created and gives me this error: "A MediaStreamTrack ended due to capture failure" It only happens in "standalone" web apps that have been saved to the user homescreen.
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to SwiftUI Chart Axis Alignment Issue
@kbista Did you ever figure out a fix to this? I am still having this problem where charts is centering points inside of the columns on the x-axis.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24