On 5 Jun 2016, at 02:25, Matthias Zenger <matth...@objecthub.net> wrote:

> I still don't understand if it's currently actually *possible* to use non 
> C-based solutions in Swift which use streaming. 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.

Ah, yes, that’s definitely something you should be wary of.  I don’t know what 
the plan is for getting NSFileHandle to play nicely with Swift.  Maybe someone 
else will chime in.

> Are there any alternatives?

You could always use NSStream.

However, building Swift code on top of NSStream is about as difficult as 
building it on top of UNIX system calls (open/close/read/write) or stdio 
(fopen/fclose/fread/fwrite), so if you need streaming file I/O you might as 
well do that.

Give it a go and let us know if you get stuck.

Finally, as has been mentioned on this thread already, it’s easy to imagine a 
Swift streaming file I/O that’s /much/ better than these options, although 
AFAIK there are no concrete plans for that.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to