I have some code that currently uses NSArrays to save data to a file. The file size is too large for my needs so I wanted to be able to write an array of doubles to a file while possibly also pruning some of the insignificant bits.
var arr: [[Float]] = []
arr.append([Double(1.0), Double(2.0), Double(3.0)]
arr.append([Double(4.0), Double(5.0), Double(6.0)]
if let outputStream = OutputStream(url: getFileUrl(), append: true) {
outputStream.open()
for sub_array in arr {
for item in sub_array {
outputStream.write(one_quarter_of_bits(item))
}
}
outputStream.close()
}
Above is the psuedo-code. It is an important design goal that the file be as small as possible including dropping some of the insignificant bits.