Skip to content

Instantly share code, notes, and snippets.

@austenstrine
Last active February 28, 2019 04:18
Show Gist options
  • Save austenstrine/832feae5c623b09f3a57b28ad4a8f105 to your computer and use it in GitHub Desktop.
Save austenstrine/832feae5c623b09f3a57b28ad4a8f105 to your computer and use it in GitHub Desktop.
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