Post

Replies

Boosts

Views

Activity

Reply to What is the best SwiftData approach to replicate NSManagedObject's willSave?
After some research I went with the first option, but half-hiding properties behind transient versions. This makes it clear when something is going to be modified. Unfortunately I can't change the post title at this point - which was based on my previous experience with Core Data. ModelContext.willSave is sent rarely on macOS - for example when the app moves into the background. Changes to many models can happen between notifications. Using the willSave approach would cause issues with undo etc. private(set) var text: String = "" var textModify: String { get { text } set { text = newValue modified = Date.now } }
Oct ’24
Reply to NavigationSplitView TabView Toolbar Clash
Thank you for your answer. I was expecting the sidebar to sit below the tab bar, alongside the detail view. Is there a way to do this on Sonoma? The current behaviour is very strange - it takes two button clicks to return to the Types tab, which then shifts the whole layout. When on the General tab the tab bar remains full width.
Topic: UI Frameworks SubTopic: SwiftUI
Jul ’24
Reply to ITSAppUsesNonExemptEncryption
If you are here, you may have accidentally added the ITSAppUsesNonExemptEncryption key to your entitlements file, rather than to your info.plist file.
Replies
Boosts
Views
Activity
Nov ’24
Reply to What Is The Recommended View Hierarchy for SwiftData Many-Many Relationships?
I have found that the predicate building for a many-many relationship works in the following form: let itemsIDs = day.show?.map { $0.persistentModelID } ?? [] let predicate = #Predicate<Item> { item in itemsIDs.contains(item.persistentModelID) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to What is the best SwiftData approach to replicate NSManagedObject's willSave?
After some research I went with the first option, but half-hiding properties behind transient versions. This makes it clear when something is going to be modified. Unfortunately I can't change the post title at this point - which was based on my previous experience with Core Data. ModelContext.willSave is sent rarely on macOS - for example when the app moves into the background. Changes to many models can happen between notifications. Using the willSave approach would cause issues with undo etc. private(set) var text: String = "" var textModify: String { get { text } set { text = newValue modified = Date.now } }
Replies
Boosts
Views
Activity
Oct ’24
Reply to NavigationSplitView TabView Toolbar Clash
OK, thank you for your feedback. I will look to manage the state differently and use a standard HSplitView.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jul ’24
Reply to NavigationSplitView TabView Toolbar Clash
Thank you for your answer. I was expecting the sidebar to sit below the tab bar, alongside the detail view. Is there a way to do this on Sonoma? The current behaviour is very strange - it takes two button clicks to return to the Types tab, which then shifts the whole layout. When on the General tab the tab bar remains full width.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jul ’24
Reply to Are CKRecords Guaranteed to be Added to an NSPersistentCloudKitContainer Store in creationDate order?
Further to this. It appears that the error "[error] CoreData: Metadata Inconsistency: Missing metadata for record:" leads to these duplication errors. Perhaps this relates to a Share Extension being killed part way through the sync process? How can I avoid this issue?
Replies
Boosts
Views
Activity
Jul ’22
Reply to LPMetadataProvider never returns in SFSafariExtensionHandler
It seems that LPMetadataProvider can only be used on the main thread. This doesn't seem to be documented anywhere! So, the fix is: Task { @MainActor guard let properties = await page.properties(), ...
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to How to Drag and Drop Images in SwiftUI on macOS
I am seeing this error too. Did you ever find a solution to this?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’22