On 9 Mar 2021, at 12:10, Jean-Daniel wrote:

If I had to write a new software that need read/write functions today, I would go for a modern async API, like dispatch_io.

This came up while trying to generalize a few things I have that basically transform data, but where size is unknown, and the transformation can be done incrementally.

The dispatch IO API is more like a wrapper for kqueue than an interface that can be used to pass data between components.

Based on the description, the Security Transforms API should be closer to what I am looking for, from the overview: “You use security transforms to assemble a chain of security-related operations that you apply to a stream of data in macOS”.

Though new use of this API is discouraged, it only has C functions, and I never got whether or not this API was supposed to allow custom transformations (inserted into the pipeline).

But while NSStream is not discouraged per se, the very sparse use of this API does indicate that Apple doesn’t embrace the idea.

There are however examples where “streaming” could have been used. Take e.g. NSData, it has an enumerateByteRangesUsingBlock: method, this is effectively the same as “write to output stream” but with an ad hoc API that only applies to NSData and cannot be “connected” to anything else.

Granted, calling enumerateByteRangesUsingBlock: with a block is much simpler than creating an NSOutputStream subclass, but that’s in large part because we lack a proper ecosystem of stream classes, for example we could have a simple outputStreamWithBlock: convenience method for when we just want to consume the data at one location.

Btw: Thanks for engaging in my thread :)
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to