aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Utility
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-01-03 15:40:24 -0800
committerDustin Mierau <dustin@mierau.me>2024-01-03 15:40:24 -0800
commit64368ad8690f0a071f2490e8429c0437694133ee (patch)
tree2e0eac2130ff39498ccab2fa8f6abf905f7c5a4d /Hotline/Utility
parent4d31accad9d6bf901928f4293f29cb62f6f77260 (diff)
Fix issue with username saving to server with each change in username textfield.
Diffstat (limited to 'Hotline/Utility')
-rw-r--r--Hotline/Utility/TextDocument.swift8
1 files changed, 5 insertions, 3 deletions
diff --git a/Hotline/Utility/TextDocument.swift b/Hotline/Utility/TextDocument.swift
index 3904a21..82727de 100644
--- a/Hotline/Utility/TextDocument.swift
+++ b/Hotline/Utility/TextDocument.swift
@@ -16,14 +16,16 @@ struct TextFile: FileDocument {
// this initializer loads data that has been saved previously
init(configuration: ReadConfiguration) throws {
+
if let data = configuration.file.regularFileContents {
- text = String(decoding: data, as: UTF8.self)
+ if let str = String(data: data, encoding: .utf8) {
+ self.text = str
+ }
}
}
// this will be called when the system wants to write our data to disk
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
- let data = Data(text.utf8)
- return FileWrapper(regularFileWithContents: data)
+ return FileWrapper(regularFileWithContents: self.text.data(using: .utf8)!)
}
}