What are the closure parameters for the Swift version of "Data.enumerateBytes"?
What are the closure parameters for the Swift version of "Data.enumerateBytes"?
- Subject: What are the closure parameters for the Swift version of "Data.enumerateBytes"?
- From: Daryle Walker <email@hidden>
- Date: Sat, 09 Sep 2017 09:58:50 -0400
The method signature is:
public func enumerateBytes(_ block: (UnsafeBufferPointer<UInt8>, Data.Index,
inout Bool) -> Swift.Void)
From trying out the version from NSData in Objective-C years ago, and this
method’s own explanation, I know the third closure parameter controls whether
to keep iterating. Instead of a pointer and a range, we have a buffer and index
for the first two closure parameters. I guess the span information has just
moved from the second to the first parameter. The first parameter has changed
from a pointer to the start of the memory segment to a buffer enclosing the
segment’s start and span. The second parameter used to represent which span of
bytes within the total NSData object are modeled in the segment, now I guess
it’s now the index within the Data object where the modeled segment starts. Is
my guess correct?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden