Post

Replies

Boosts

Views

Activity

Reply to [SwiftData] Bugs with `autosaveEnabled` and `undoManager` + Observation
I was experiencing the same issue, but I managed to put together an admittedly "hacky" workaround--it does seem to work, though. The basic idea is to call undoNestedGroup to cancel all the changes the user might have made, but then make a subtle change on the model object in code, revert the change, and then call save on the context. This will force the model to think that there was a change, and it will update the parent form. Here's some code that illustrates the approach that I put in the Cancel button on the action sheet where the object is edited: undoManager?.endUndoGrouping() undoManager?.undoNestedGroup() let title = request.title request.title = request.title + " " request.title = title try! context.save()` Hopefully this issue will get resolved or someone will come up with a much more elegant solution, but maybe this will work in the meantime.
Topic: App & System Services SubTopic: General Tags:
Feb ’24
Reply to Apple Watch Missing Developer Mode Option
I was also having the issue where my watch was not showing up in the list of devices, nor did I have an option to enable developer mode. I followed @Igor-ribeiro-dev's advice, but with some modifications: Unplug the iPhone from Mac Unpair the iPhone from Xcode **On iPhone, clear all trusted computers (Settings > Developer > Clear Trusted Computers) Disable developer mode on iPhone Enable developer mode and restart the iPhone **Quit out of Xcode Plug in iPhone via USB cable, and Trust computer **Open Xcode, and try to run app on iPhone, at which point iPhone will prompt you to trust computer again, so do it. Xcode should also detect your watch Enable developer mode on watch Run app on the watch. I think the issue I was having was when I was plugging my iPhone into my Mac, I also had Xcode open, and so both "trust" messages weren't getting through, because I didn't have time to respond to the first one (entering my PIN) before the second one would pop up. By waiting to open Xcode until after I trusted the computer initially, things seemed to work fine for me. Hope that's helpful for anyone else that might be struggling with this.
Feb ’24
Reply to ShareLink and DataRepresentation
There is a suggestedFileName func on TransferRepresentation that you can use to provide a default file name, if you just want to avoid the "comma-separated-values" value that Apple defaults to. static var transferRepresentation: some TransferRepresentation { DataRepresentation(exportedContentType: .csv) { archive in try archive.convertToCSV() } .suggestedFileName("Archived Data.csv") } When you share your object, it should then default to a file name of "Archived Data.csv". Note that this parameter is attached to the static var, so you won't get access to any instance fields within your data to generate a more dynamic file name.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to Crash during batch deletion merge when positive fractional decimals are stored and used in a derived attribute
Thank you. Yes, I have submitted a feedback report. Here's the ID: FB16507733. For now, since I'm storing dollar amounts in this field, I've switched to using an int data type to take advantage of base-10 representation, and I'm just storing cents. Then in my extension, I'm handling the conversion with a property set/get.
Mar ’25