Skip to content

Instantly share code, notes, and snippets.

@toddkramer
Last active August 29, 2015 14:12
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 toddkramer/36aead549fd5af1598b8 to your computer and use it in GitHub Desktop.
Save toddkramer/36aead549fd5af1598b8 to your computer and use it in GitHub Desktop.
ExtensionDataSharing03-Book.swift
import UIKit
public class Book: NSObject, NSCoding {
public let title: String!
public let author: String!
public init(title: String, author: String) {
self.title = title
self.author = author
super.init()
}
required public init(coder aDecoder: NSCoder) {
self.title = aDecoder.decodeObjectForKey("title") as String?
self.author = aDecoder.decodeObjectForKey("author") as String?
}
public func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(self.title, forKey: "title")
aCoder.encodeObject(self.author, forKey: "author")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment