Home > Enterprise >  What are all the OS keys of UserDefaults and what do they mean?
What are all the OS keys of UserDefaults and what do they mean?

Time:10-14

When I get

UserDefaults.standard.dictionaryRepresentation()

from any app, I can recover a list of many keys-values (that weren't saved by my application) like

AKLastCheckInAttemptDate
AKLastCheckInSuccessDate
com.apple.content-rating.AppRating
INNextFreshminRefreshDateKey
INNextHearbeatDate
and others

I searched through the internet and in the Apple documentation but I didn't find any list of possible keys that can be used by the operating system, much less what exactly each of these keys means. Does anyone know any such list or know what each of these keys mean?

CodePudding user response:

The set of keys is not fixed or, in general, documented. Any string can be used as a key.

UserDefaults.standard is a global object in your app. So any framework used in your app has access to UserDefaults.standard and can set own entries, using any keys it wants. Some settings are even shared across the whole system and so they can be set by other apps or by frameworks you don't use in your app.

The keys and values used by an app or framework are usually considered to be implementation details, so Apple doesn't want you to rely on anything their code stores in UserDefaults.standard.

You would need to read the source code of an app or framework to understand what keys it might set and what they mean, but Apple releases very little of its source code. You could also try reverse-engineering the app or framework (that is, disassembling it and figuring out what it does from the machine instructions) but that is usually very difficult.

  • Related