Skip to content

Instantly share code, notes, and snippets.

View fishfisher's full-sized avatar

Erik Fisher fishfisher

View GitHub Profile
@danurna
danurna / RealmSwift+Extension.swift
Last active September 26, 2017 07:29
Cascade Delete Realm Swift
import Foundation
import Realm
import RealmSwift
public extension Realm {
func cascadeDelete(_ entity: RLMObjectBase) {
guard let entity = entity as? Object else { return }
entity.objectSchema.properties.forEach { property in
@JohnSundell
JohnSundell / OnboardingManager.swift
Last active May 21, 2020 08:19
An example of using #function for user defaults properties, and a test that guards against property name changes
import UIKit
class OnboardingManager {
private let userDefaults: UserDefaults
init(userDefaults: UserDefaults = .standard) {
self.userDefaults = userDefaults
}
func presentOnboardingControllerIfNeeded(in viewController: UIViewController) {
@gregpardo
gregpardo / Realm+CascadingDeletions.swift
Last active June 14, 2017 15:46
Realm+CascadingDeletions
import Foundation
import RealmSwift
protocol CascadingDeletable {
var cascadingDeletions: [AnyObject?] { get }
}
extension Realm {
func delete<T: AnyObject>(cascading: List<T>) where T: CascadingDeletable {