Since
NSKeyedUnarchiver.unarchiveTopLevelObjectWithData
has been deprecated as of macOS 14.0 I am trying to load legacy NSCoder archives now using NSSecureCoding set in the class and using:
coder.unarchivedObject(ofClasses classes: [AnyClass], from data: Data)
to load the archive. The archive loads and most of the class members can be extracted. However, Swift Arrays always come out nil even though
coder.containsValue(forKey:)
returns true. The arrays were encoded with:
var pageUsesClearBackground: Array<Bool> = [true, true, true, true]
coder.encode(pageUsesClearBackground, forKey: "CB_KEY")
Using:
pageUsesClearBackground = coder.decodeObject(forKey: "CB_KEY") as? Array<Bool>
Brings back an array with 0 values, even though if I use the non NSSecureCode version, the Array is populated.
pageUsesClearBackground [Bool] 0 values
I suspect this has something to do with Arrays in Swift are a struct and do not conform to NSCoding. Odd that it worked encoding and decoding them for years. Any idea how to retrieve class members that are Arrays from an archive made before NSSecureCoding?
Apparently, NSSecureCoding is so secure you can't even get the data back.
Post
Replies
Boosts
Views
Activity
I have a macOS app built with Xcode 14.1 that works perfectly on Catalina through Ventura. Works on Apple Silicon and Intel machines. When it runs under Sonoma (9/12/23 release and earlier) controls in dialog boxes no longer highlight blue but can be pressed. Text fields can not be edited. Radio buttons can be selected but they all stay gray. This happens to not only the app's custom dialogs but Apple's NSSavePanel() and others. It happens in Sonoma with Apple Silicon or Intel versions under Rosetta. An earlier version built with Xcode 13 works just fine (except WebKit has issues). I made a small app that just tries to do a NSAlert() and it works correctly in Sonoma built with Xcode 14.1. I have not seen any other apps do this under Sonoma.
In order to rule out some sort of byzantine focus problem with the view controllers in the app, I removed everything from applicationDidFinishLaunching() and put an NSAlert() in there. Same thing, the default button comes out gray and not blue.
I've tried bumping up the minimum release to macOS 12.x. No luck.
It's nothing to do with Appearance, I have removed all of that code. Deleted all the prefs.
I've rebuilt the project file in Xcode 14.1 from scratch, same thing - no blue focus buttons. I've tried building it with the latest versions of Xcode and the same problem. Any ideas what in the world can cause this?
Hello -
I’m creating an app that needs to copy ColorSync profiles to the /Library/ColorSync/Profiles directory on macOS and was wondering what is the correct / sanctioned way to write to the /Library directory is?
The app won’t be in the App Store. The app needs to run on Big Sur through Sonoma.
I spent some time working with ColorSyncProfileInstall() but that seems to want to ask the user permission every single time the function is called - and this app can install up to 25 profiles at a time. (There are actually hundreds of profiles that can be chosen that will come from a server).
I’m currently looking at using SMJobBless but that sure seems like using an atomic bomb to swat a mosquito. Any thoughts if SMJobBless is the right way to go? (SMAppService for 13 and on).
Thanks!
Is there a way out of the WeatherKit REST API to get a textual summary of the weather like the iPhone app from Apple shows? Right now the local forecast on the iPhone app says "Sunny conditions from 7pm-8pm, with partly cloudy conditions expected at 8PM". Is this something the app rolls on it's own or is there a attribute-value pair in one of the returned JSON datasets that has this text. It's not in the "forecastDaily" dataset.
*Humorous that it says "Sunny conditions from 7pm-8pm" because that's about the time the sun is setting. That forecast was from 1PM.