• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Data, enumerateBytes: separate blocks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data, enumerateBytes: separate blocks?


  • Subject: Re: Data, enumerateBytes: separate blocks?
  • From: Daryle Walker <email@hidden>
  • Date: Thu, 21 Dec 2017 21:04:32 -0500

> On Dec 19, 2017, at 8:08 PM, Quincey Morris
> <email@hidden> wrote:
>
> On Dec 19, 2017, at 14:57 , Daryle Walker <email@hidden
> <mailto:email@hidden>> wrote:
>>
>> What are the hoops/bridges required?
>
> I think I was referring to what Wim Lewis said, which is that you can create
> DispatchData values (or perhaps dispatch_data_t objects), but you’re going to
> have to forcibly cast from dispatch_data_t to its superclass, and then bridge
> that to Data.
>
> However, if you’re going to the trouble of creating DispatchData values, you
> may as well use those directly, rather than bridging across to Data. The
> decision may depend on exactly which APIs you need to use to process the data.

I need to test when multiple blocks are used:

>         // Find the first occurance of each potential terminator byte value.
>         var firstCr, firstLf: Index?
>         enumerateBytes { buffer, start, stop in
>             if let localLf = buffer.index(of: ParsingQueue.Constants.lf) {
>                 firstLf = start.advanced(by: buffer.startIndex.distance(to:
> localLf))
>                 stop = true
>             }
>
>             if let firstCrIndex = firstCr, firstCrIndex.distance(to:
> start.advanced(by: buffer.count)) > 2 {
>                 // No block after this current one could find a LF close
> enough to form CR-LF or CR-CR-LF.
>                 stop = true
>             } else if let localCr = buffer.index(of:
> ParsingQueue.Constants.cr) {
>                 firstCr = start.advanced(by: buffer.startIndex.distance(to:
> localCr))
>                 stop = true
>             }
>         }

(This is in an extension of Data.) Right now, I have no way to activate the
second IF-block for testing.

—
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

  • Follow-Ups:
    • Re: Data, enumerateBytes: separate blocks?
      • From: Quincey Morris <email@hidden>
References: 
 >Re: Data, enumerateBytes: separate blocks? (From: Daryle Walker <email@hidden>)
 >Re: Data, enumerateBytes: separate blocks? (From: Quincey Morris <email@hidden>)

  • Prev by Date: IKScannerDeviceView not working
  • Next by Date: Re: Data, enumerateBytes: separate blocks?
  • Previous by thread: Re: Data, enumerateBytes: separate blocks?
  • Next by thread: Re: Data, enumerateBytes: separate blocks?
  • Index(es):
    • Date
    • Thread