Skip to content

Instantly share code, notes, and snippets.

@LeeKahSeng
Created February 15, 2018 04:50
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 LeeKahSeng/fe85b75c36fd0d2efe863bc5ddfa1d86 to your computer and use it in GitHub Desktop.
Save LeeKahSeng/fe85b75c36fd0d2efe863bc5ddfa1d86 to your computer and use it in GitHub Desktop.
import Foundation
import CoreData
import UIKit
@objc(TestEntity)
public class TestEntity: NSManagedObject {
var image: UIImage {
set {
base64 = base64(from: image)
}
get {
return image(from: base64!)
}
}
}
extension TestEntity {
func base64(from image: UIImage) -> String {
// ************************************** //
// UIImage to base64 encoding logic here! //
// ************************************** //
return "base64-encoded-string"
}
func image(from base64: String) -> UIImage {
// ************************************** //
// base64 to UIImage decoding logic here! //
// ************************************** //
return UIImage()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment