Skip to content

Instantly share code, notes, and snippets.

@oliverepper
Created February 21, 2020 16:46
Show Gist options
  • Save oliverepper/221b5f85073ef9b7cff3e9ee83d0f039 to your computer and use it in GitHub Desktop.
Save oliverepper/221b5f85073ef9b7cff3e9ee83d0f039 to your computer and use it in GitHub Desktop.
CodableFileBuffer
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