Skip to content

Instantly share code, notes, and snippets.

@igorescodro
Created October 17, 2023 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorescodro/887de513c6c29d9380d9a6def4091bdf to your computer and use it in GitHub Desktop.
Save igorescodro/887de513c6c29d9380d9a6def4091bdf to your computer and use it in GitHub Desktop.
@OptIn(ExperimentalForeignApi::class)
fun getDataStore(): DataStore<Preferences> = getDataStore(
producePath = {
val documentDirectory: NSURL? = NSFileManager.defaultManager.URLForDirectory(
directory = NSDocumentDirectory,
inDomain = NSUserDomainMask,
appropriateForURL = null,
create = false,
error = null,
)
requireNotNull(documentDirectory).path + "/$dataStoreFileName"
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment