Last active
February 28, 2019 04:18
-
-
Save austenstrine/832feae5c623b09f3a57b28ad4a8f105 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import CoreData | |
class CopyingCodable : Encodable, Decodable, NSCopying | |
{ | |
func copy(with zone: NSZone? = nil) -> Any | |
{ //this is like...the ugliest code I've ever written | |
return try! JSONDecoder().decode( | |
type(of: self), | |
from: try! JSONEncoder().encode(self) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment