Out-of-Process NSUserDefaults.

So I’m debugging a performance issue in Binaural, and this trace shows up in Instruments:

BinauralKit.Defaults.beatFrequency.setter : Swift.Double
 -[NSUserDefaults(NSUserDefaults) setObject:forKey:]
   -[CFPrefsPlistSource sendFullyPreparedMessage:settingValue:forKey:]

Which means NSUserDefaults is handled out-of-process. I had no idea.

The XPC call has a service name of com.apple.cfprefsd.daemon. I’m assuming that means “Core Foundation Preferences Daemon”.

NSUserDefaults used to be, pretty much, an in-memory cache of a plist file. And it still is, except now it seems that in-memory cache resides in a different process - so while you’re still not doing disk I/O, you might run into performance issues due to (local) network I/O.

This is benign unless you’re updating your defaults in a tight loop. Or at 60fps, just like I was.

Is this new in iOS 8, or did I just miss it so far?

What’s the rationale for doing this over XPC?

I’d love to know.