Re: Data, enumerateBytes: separate blocks?
Re: Data, enumerateBytes: separate blocks?
- Subject: Re: Data, enumerateBytes: separate blocks?
- From: Quincey Morris <email@hidden>
- Date: Thu, 21 Dec 2017 20:10:27 -0800
On Dec 21, 2017, at 18:04 , Daryle Walker <email@hidden> wrote:
>
> when multiple blocks are used
At this point, I don’t understand what you don’t understand. Here’s a code
fragment that works in a playground:
> import Foundation
>
> let buffer1: [UInt8] = [1,2]
> let buffer2: [UInt8] = [3,4,5,6]
>
> var data = DispatchData.empty
> data.append (buffer1.withUnsafeBytes { DispatchData (bytesNoCopy: $0) })
> data.append (buffer2.withUnsafeBytes { DispatchData (bytesNoCopy: $0) })
>
> print (data.count)
> data.enumerateBytes {
> bytes, index, stop in
> print (bytes.count, index, bytes [0])
> }
producing this output:
> 6
> 2 0 1
> 4 2 3
Isn’t this what you were asking for: a loop enumerating each of the contiguous
portions of a larger data set?
_______________________________________________
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