Skip to content

Instantly share code, notes, and snippets.

@AlexanderKozhevin
Created January 15, 2020 14:27
Show Gist options
  • Save AlexanderKozhevin/eef343b7e3e221b42bc789e3ea7db688 to your computer and use it in GitHub Desktop.
Save AlexanderKozhevin/eef343b7e3e221b42bc789e3ea7db688 to your computer and use it in GitHub Desktop.
func StorageSave(key: String, value: String){
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDelegate.persistentContainer.viewContext
let store = context.persistentStoreCoordinator?.persistentStores.first
let coordinator = context.persistentStoreCoordinator
if let store = context.persistentStoreCoordinator?.persistentStores.first {
let metadata = fillMetadata(store: store, key: key, value: value)
store.metadata = metadata
do {
try coordinator?.setMetadata(["push_url": value], for: store)
try context.save()
} catch {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment