Skip to content

Instantly share code, notes, and snippets.

@ebubekirsezer
Created October 22, 2022 09:05
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 ebubekirsezer/1abfa15be5a250e03a8e8c440a64a86a to your computer and use it in GitHub Desktop.
Save ebubekirsezer/1abfa15be5a250e03a8e8c440a64a86a to your computer and use it in GitHub Desktop.
//
// RealmHelper.swift
// GitStar
//
// Created by EbubekirSezer on 22.10.2022.
//
import Foundation
class RealmHelper {
static func DetachedCopy<T:Codable>(of object:T) -> T? {
do {
let json = try JSONEncoder().encode(object)
return try JSONDecoder().decode(T.self, from: json)
}
catch let error {
print(error)
return nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment