Skip to content

Instantly share code, notes, and snippets.

View Jon889's full-sized avatar

Jonathan Bailey Jon889

  • Elfin Market
  • UK
View GitHub Profile
@Jon889
Jon889 / RawRepresentableExtensions.swift
Last active April 21, 2016 22:54 — forked from joshavant/RawRepresentableExtensions.swift
RawRepresentable, meet NSCoding
enum Status: Int {
case Good
case Bad
}
// Status.RawValue == Int not NSData, therefore this extension should not be applied to status
extension RawRepresentable where RawValue == NSData, Self: NSCoding {
init?(rawValue: NSData) {
if let instance = NSKeyedUnarchiver.unarchiveObjectWithData(rawValue) as? Self {
self = instance