Skip to content

Instantly share code, notes, and snippets.

View tarangpatel's full-sized avatar

Tarang Patel tarangpatel

View GitHub Profile
@krodak
krodak / Realm+CascadeDeleting.swift
Last active April 27, 2023 19:16
Cascade deletion for RealmSwift
import RealmSwift
import Realm
protocol CascadeDeleting: class {
func delete<Entity>(_ list: List<Entity>, cascading: Bool)
func delete<Entity>(_ results: Results<Entity>, cascading: Bool)
func delete<Entity: Object>(_ entity: Entity, cascading: Bool)
}
@samwize
samwize / DynamicKey.swift
Created September 28, 2017 06:59
A CodingKey that is dynamic -- it can be any string! Encode/decode with a Dictionary of `[String : Any]` in the model.
/**
```
// Encode a model with properties of type [String : Any]
var propertiesContainer = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .properties)
if let properties = properties {
try propertiesContainer.encodeDynamicKeyValues(withDictionary: properties)
}
```
*/
struct DynamicKey: CodingKey {