Created
February 21, 2020 16:46
-
-
Save oliverepper/221b5f85073ef9b7cff3e9ee83d0f039 to your computer and use it in GitHub Desktop.
CodableFileBuffer
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 func append(_ codable: T) { | |
// encode codable | |
guard let data = try? encoder.encode(codable) else { | |
fatalError("Cannot encode \(codable)") | |
} | |
// write to FileHandle | |
fileHandle.write(data) | |
fileHandle.write(",".data(using: .utf8)!) | |
// log | |
os_log("Did append codable to CodableFileBuffer at: %@", log: OSLog.CodableFileBuffer, type: .debug, fileURL.lastPathComponent) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment