feat: delete the selected note
This commit is contained in:
@@ -63,6 +63,14 @@ public final class NotesStore {
|
||||
notes[index] = note
|
||||
}
|
||||
|
||||
public func delete(id: UUID) throws {
|
||||
guard let index = notes.firstIndex(where: { $0.id == id }) else {
|
||||
throw CocoaError(.fileNoSuchFile)
|
||||
}
|
||||
try FileManager.default.removeItem(at: directory.appendingPathComponent(id.uuidString + ".rtfd"))
|
||||
notes.remove(at: index)
|
||||
}
|
||||
|
||||
private func save(_ note: Note) throws {
|
||||
let wrapper = try note.contents.fileWrapper(
|
||||
from: NSRange(location: 0, length: note.contents.length),
|
||||
|
||||
Reference in New Issue
Block a user