NSUserDefaults no-go macOS, Objective-C, Big Sur

Called in 'applicationDidFinishLaunching'. Return 'b' is YES but it does not work. Also if 'synchronize' is to be deprecated what to use? Also, cannot find where it should be stored in /library/preferences/ ?? How else to store needed unique user data?

NSString *valueToSave = @"3";
[[NSUserDefaults standardUserDefaults] setObject:valueToSave forKey:@"infoDLG"];
BOOL b = [[NSUserDefaults standardUserDefaults] synchronize];

Any help appreciated, Paul. (Sorry, no idea what Tags to use.)

Replies

What do you want to achieve ?

I do this, which works (in Swift, but easy to adapt).

In DidFinishLaunching:

        let defaults = UserDefaults.standard
        let h = defaults.bool(forKey: "someKey")

When I need to save:

        let defaults = UserDefaults.standard
        let h = true //  the value to save
        defaults.set(h, forKey: "someKey")

In fact, I don't even use synchronise.

PS: MacOS could be a relevant tag