[swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

Jens Alfke jens at mooseyard.com
Thu May 19 11:38:34 CDT 2016


> On May 19, 2016, at 12:58 AM, Quinn The Eskimo! via swift-users <swift-users at swift.org> wrote:
> 
> The reason I ask is that most of the time when I mess around with files I transfer the entire file to and from memory, which is something that the Foundation APIs excel at.

I believe Mac/iOS developers usually transfer the entire file because that’s the particular hammer that Foundation provides. For some reason Foundation has never had good stream APIs (and they used to be worse!), so it’s much more convenient to just use NSData or NSString methods to read and write the entire file, than it is to mess around with NSFileHandle or NSStream.

Conversely, most other platforms (certainly C/POSIX and Java) make it easier to stream the file (which I believe is more efficient; certainly more scalable) than to block-read/write it.

I’m hoping that the Swift translation of Foundation provides greatly-improved Stream classes.

—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160519/40f98c96/attachment.html>


More information about the swift-users mailing list