[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
Sun Jun 5 13:36:31 CDT 2016
> On Jun 4, 2016, at 6:25 PM, Matthias Zenger via swift-users <swift-users at swift.org> wrote:
>
> I wanted to use NSFileHandle (for a use case that requires streaming) and realized that this is an API that cannot really be used in Swift because it's based on Objective-C exceptions.
You’re right, NSFileHandle is a very archaic class (kind of a coelacanth) and its I/O methods signal errors by throwing exceptions. It’s almost unique in that regard; in general Cocoa APIs are only supposed to throw exceptions for programmer errors like assertion failures.
> Are there any alternatives?
NSStream.
—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160605/0b7e7ed1/attachment.html>
More information about the swift-users
mailing list