diff --git a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CKRecordWrapper.swift b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CKRecordWrapper.swift index 68952c4..8384bd8 100644 --- a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CKRecordWrapper.swift +++ b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CKRecordWrapper.swift @@ -9,7 +9,7 @@ import Foundation import CloudKit -protocol CKRecordWrapper : VendsCoding { +protocol CKRecordWrapper { static var RecordType: String { get } var record: CKRecord { get } diff --git a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CloudKitFolder.swift b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CloudKitFolder.swift index dcb19c6..8586a24 100644 --- a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CloudKitFolder.swift +++ b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/CloudKitFolder.swift @@ -37,13 +37,3 @@ class CloudKitFolder : Folder, CKRecordWrapper { self.record = record } } - -extension CloudKitFolder { - static func defaultFolder(inZone zoneID: CKRecordZoneID) -> CloudKitFolder { - let recordID = CKRecordID(recordName: "DEFAULT_FOLDER", zoneID: zoneID) - let record = CKRecord(recordType: CloudKitFolder.RecordType, recordID: recordID) - let folder = CloudKitFolder(record: record) - folder.name = "My Notes" - return folder - } -} diff --git a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/Folder.swift b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/Folder.swift index cb9bd1e..69cc85d 100644 --- a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/Folder.swift +++ b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/Folder.swift @@ -8,12 +8,7 @@ import Foundation -protocol VendsCoding { - func codable() -> NSCoding - static func fromCoding(decoder: NSCoder) -> Folder? -} - -protocol Folder : VendsCoding { +protocol Folder { var identifier: String? { get } var name: String { get set } var createdAt: Date? { get } diff --git a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/FoldersDatasource.swift b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/FoldersDatasource.swift index be44c49..39409a7 100644 --- a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/FoldersDatasource.swift +++ b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/FoldersDatasource.swift @@ -9,7 +9,6 @@ import Foundation class FoldersDatasource { - let cache = DiskCache(name: "folders") let noteManager: NotesManager init(noteManager: NotesManager) { @@ -17,20 +16,9 @@ class FoldersDatasource { } func fetchFolders(completion: @escaping (Result<[Folder]>) -> Void) { - let cachedFolders: [Folder]? = cache.fetch() - if let folders = cachedFolders { - DispatchQueue.main.async { - print("Returning cached folders...") - completion(.success(folders)) - } - } - noteManager.fetchFolders { result in switch result { case .success(let folders): - let codableFolders = folders.map { $0.codable() } - print("Caching updated results...") - self.cache.save(object: codableFolders) DispatchQueue.main.async { completion(.success(folders)) } diff --git a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryFolder.swift b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryFolder.swift index f3efd33..0d1980d 100644 --- a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryFolder.swift +++ b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryFolder.swift @@ -8,7 +8,7 @@ import Foundation -class InMemoryFolder : Folder, NSCoding, VendsCoding { +class InMemoryFolder : Folder, NSCoding { var identifier: String? var name: String var createdAt: Date? diff --git a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryNote.swift b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryNote.swift index a40c95f..54fcfb0 100644 --- a/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryNote.swift +++ b/275-extracting-ckrecordwrapper/SharedNotes/SharedNotes/InMemoryNote.swift @@ -8,7 +8,7 @@ import Foundation -class InMemoryNote : Note, NSCoding, VendsCoding { +class InMemoryNote : Note, NSCoding { var identifier: String? var content: String = "" var createdAt: Date?