> On 3 Apr 2021, at 16:34, Richard Charles via Cocoa-dev > <cocoa-dev@lists.apple.com> wrote: > >> >> On Apr 3, 2021, at 8:59 AM, Gabriel Zachmann <z...@cs.uni-bremen.de> wrote: >> >> Thanks a lot for your response! >> >>> How about something like this? >>> >>> NSUserDefaults *monitor1 = [[NSUserDefaults alloc] init]; >>> [monitor1 setBool:YES forKey:@"MyKey”]; >>> >>> BOOL value = [monitor1 boolForKey:@"MyKey"]; >> >> So, where is the kind of monitor encoded? >> I mean, how does the code distinguish between the preferences of monitor1 >> and monitor2? >> >> Can you explain to me, what is the difference between >> [[NSUserDefaults alloc] init] >> and >> [NSUserDefaults standardDefaults] >> ? >> I didn't get that from Apple's docs. >> > > > From the docs - init returns an initialized NSUserDefaults object whose > argument and registration domains are already set up. This method does not > put anything in the search list. Invoke it only if you’ve allocated your own > NSUserDefaults instance instead of using the shared one. > > So it appears that using alloc int does not return the shared instance.
Where in the docs do you read that? The current NSUserDefaults docs say contrary: > Creates a user defaults object initialized with the defaults for the app and > current user. https://developer.apple.com/documentation/foundation/nsuserdefaults/1414356-init?language=objc <https://developer.apple.com/documentation/foundation/nsuserdefaults/1414356-init?language=objc> Mike. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com