Elektrine lite

← Feed

@isaiah@mastodon.social

Post #825818

2026-03-28 18:43 UTC

i’d like to save some “workspace” type settings: settings that are tied to the document rather than to the app itself. things like the selected tab, the sidebar widths, etc.these need to persist even if the user doesn’t save the document — so they’re definitely settings, not document data. anyone else doing this? i was hoping there was some hidden corner of NSUserDefaults that handled this, but that doesn’t seem to be the case.

Replies (3)

  • @tapforms@mastodon.social 2026-03-29 00:55

    @isaiah@mastodon.social I've been doing that for years now. Just a dictionary of key values stored in a plist file within the document bundle. I just load it in when the document is instantiated. I modeled it directly after NSUserDefaults. I called it ..... TFUserDefaults. Very original 😆

    Open ##830351

  • @troz@mastodon.social 2026-03-29 01:54

    @isaiah@mastodon.social For SwiftUI, SceneStorage is like AppStorage only per window. I don’t know how to map this to UserDefaults but there must be a link.

    Open ##830962

  • @isaiah@mastodon.social I sometimes save these things as xattributes in the document itself. If you want them to be use-specific though, you'd probably be better off saving a separate per-document file in ApplicationSupport or something

    Open ##836752