Post

Replies

Boosts

Views

Activity

Tapping button in Widget does not update App until force quit
I think this is a bug, but figured I'd double check in case I missed something stupid. I have the following model: class Thread { var id: UUID var timestamp: Date var style: String var fit: String var brand: String var size: String @Attribute(.externalStorage) var image: Data? @Relationship(deleteRule: .cascade) var worn: [TimesWorn] var wornCount: Int @Relationship(deleteRule: .cascade) var washed: [TimesWashed] var washedCount: Int @Relationship(deleteRule: .cascade) var fitPics: [FitPic] which I am accessing via the following method in my app intent file: func perform() async throws -> some IntentResult { guard let modelContainer = try? ModelContainer(for:Thread.self) else { return .result() } let descriptor = FetchDescriptor<Thread>(predicate: #Predicate {thread in thread.style == threadStyle }) let threads = try? await modelContainer.mainContext.fetch(descriptor) if let thread = threads?.first { let newWorn = TimesWorn() thread.worn.append(newWorn) thread.wornCount = thread.worn.count } return .result() } TimesWorn is super simple, just a timestamp. Basically running into two issues: when I hit the button in the widget tied to the intent, wornCount will not update in the widget UI so there is no feedback that anything has happened. if I instead use worn.count in my widget text view, it does update immediately. To add to the weirdness any places in the main application where I am using wornCount do not update until I force quit the app and relaunch. Please forgive me if I am doing something dumb here, or am asking this question stupidly. this is my first swift app and my first ever forum post! running Xcode 15 beta 6 + Simulator iOS 17 beta 5
0
0
441
Aug ’23