Attached is an entire project (4 files) that mirrors my actual project including the failure to save to file. Am I:
- missing some syntax in this code?
- failing to config a defaults file?
- not set the necessary parameters in " "Build Settings" or "Build Rules etc.?
I was writing to JSON files, but now that I must append to files directly, and JSON doesn't do that easily, I am trying to write using native macOS tools.
WELL, IT SEEMS I CAN'T SEND YOU THE CODE, TOO MANY CHARS. I CAN'T ATTACH ANY FILE EITHER. WHY OFFER IT IF IT IS NOT ALLOWED? ANYWAY, CAN YOU GLEAN ANYTHING FROM THIS... Thanks.
My debugger area: 2022-05-28 12:03:11.827372-0500 exampleClassInClassSecureCoding[1508:29981] Metal API Validation Enabled 2022-05-28 12:03:11.940123-0500 exampleClassInClassSecureCoding[1508:29981] *** NSForwarding: warning: object 0x600003cf7090 of class 'exampleClassInClassSecureCoding.classOne' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[exampleClassInClassSecureCoding.classOne replacementObjectForKeyedArchiver:] 2022-05-28 12:03:11.940416-0500 exampleClassInClassSecureCoding[1508:29981] Unrecognized selector -[exampleClassInClassSecureCoding.classOne replacementObjectForKeyedArchiver:] Unrecognized selector -[exampleClassInClassSecureCoding.classOne replacementObjectForKeyedArchiver:] Performing @selector(didPressButton:) from sender _TtC7SwiftUIP33_9FEBA96B0BC70E1682E82D239F242E7319SwiftUIAppKitButton 0x7ff08ab06480
Is there no way to to append-to-file piecemeal and then read it again?
You can absolutely do that, but you need to use a file format that supports it. The two file formats you’ve referenced, JSON and keyed archives, don’t.
If being keyed is the roadblock
No. The same restriction applies to un-keyed archives.
my original app stored as JSON text anyway
One trick commonly used by JSON folks is to use line-based JSON. That is render your JSON to a single line and then use line endings as a delimiter. For the details, see ndjson http://ndjson.org/. You can read such files by reading one line at a time and parsing each line as a separate JSON structure.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"