To save a cmbuffer to a file in Swift, you can follow these steps:
.data
property.FileManager.default.urls(for:in:)
method.write(to:options:)
method on the data, passing in the file URL and any desired options.Here is some example code to achieve this:
main.swift534 chars14 lines
Note that the .atomic
option used above overwrites the file atomically, meaning that the file is either fully written or not at all. If you don't care about atomicity, you can omit this option or use .withoutOverwriting
instead.
gistlibby LogSnag