feat: delete the selected note

This commit is contained in:
2026-10-19 19:43:25 +02:00
parent 0d9f7e0f00
commit 63d0387339
7 changed files with 156 additions and 8 deletions
+8
View File
@@ -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),