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
class Comment: Decodable { | |
let id: String | |
let text: String | |
let frame: Int | |
let annotation: String? | |
private(set) lazy var drawings: [Drawing]? = { | |
guard let annotationData = annotation?.data(using: .utf8) else { return nil } | |
return try? JSONDecoder().decode([Drawing].self, from: annotationData) | |
}() |
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
struct Annotation: Decodable { | |
let drawings: [Drawing] | |
init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
let string = try container.decode(String.self) | |
guard let data = string.data(using: .utf8) else { | |
let context = DecodingError.Context(codingPath: [], debugDescription: "Annotation data could not be serialized.") | |
throw DecodingError.dataCorrupted(context) | |
} |
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
public struct Drawing: Decodable { | |
let tool: Tool | |
let size: Int | |
let color: Color | |
} | |
extension Drawing { | |
enum Tool: String, Decodable { | |
case pen | |
case line |
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
class Comment: Decodable { | |
let id: String | |
let text: String | |
let frame: Int | |
let annotation: Annotation? | |
} |
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
{ | |
"id": "1b13-29df-c3fa-2f7b", | |
"text": "Remove logo. #legal", | |
"frame": 27, | |
"annotation": "[{\"tool\":\"pen\",\"size\":4,\"color\":\"#E74A3C\"},{\"tool\":\"arrow\",\"size\":4,\"color\":\"#E67422\"}]" | |
} |
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 UIKit | |
import NotificationCenter | |
import Books | |
class TodayViewController: UIViewController, NCWidgetProviding, UITableViewDataSource, UITableViewDelegate { | |
@IBOutlet var tableView: UITableView! | |
var booksArray = [Book]() | |
override func viewDidLoad() { |
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 UIKit | |
import Books | |
class ViewController: UIViewController { | |
var booksArray = [Book]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
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 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 |
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 UIKit | |
import NotificationCenter | |
class TodayViewController: UIViewController, NCWidgetProviding { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.preferredContentSize = CGSizeMake(320, 180); | |
println("Title: \(titleFromSharedDefaults())") |
NewerOlder