• 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: Sun, 24 Dec 2017 02:03:51 -0500

> On Dec 22, 2017, at 2:18 PM, Quincey Morris
> <email@hidden> wrote:
>
> On Dec 22, 2017, at 08:48 , Daryle Walker <email@hidden
> <mailto:email@hidden>> wrote:
>>
>> DispatchData would need to be convertible to Data.  Is there a way to do the
>> conversion in Swift?
>
> Actually, on consideration, I think not. It would be if DispatchData was
> bridgeable like Data, but it isn’t, and I don’t see any way of extracting its
> underlying reference. This leaves you with two options that I can see:
>
> 1. Use an Obj-C helper function, taking an array of input buffers, and
> returning a dispatch_data_t object that combines them, cast to a NSData*. You
> can then use the returned reference as Data.
>
> 2. Move your Data extension to DispatchData. That’s what I was asking about
> earlier — is there any reason why you couldn’t just use DispatchData rather
> than Data, in all the code that deals with this data set? In that case, you
> can just build the DispatchData in Swift.
>
> IAC, you should probably submit a bug report. Since dispatch_data_t is
> documented to be a subclass of NSData, there should probably be a mechanism
> for getting Data and DispatchData values as equivalents of each other,
> without any unprovoked copying of the underlying data.

This code is not for private use within an app, but for something I plan to
publicize as a library on GitHub. So the interface has to stay as using Data.
(Fortunately, this part of the interface, an extension to Data, is private.)
DispatchData and Data don’t even have a custom shared interface (just the
general RandomAccessCollection) I could use here to not repeat myself in
implementation.

The library doesn’t need DispatchData, just my test case (and only as posing as
a Data instance). It doesn’t seem I can do it without heroic measures by making
a mixed Swift/Objective-C test project. And even if that is possible, I don’t
even know if the Swift Package Manager supports it.  So I have to let my
meticulous side get bothered by the red-0-calls under Code Coverage mocking me
until this is fixed somehow.

Bug #36204480 (“DispatchData IS-NOT-A Data in Swift”).

—
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: Charles Srstka <email@hidden>
    • 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>)
 >Re: Data, enumerateBytes: separate blocks? (From: Daryle Walker <email@hidden>)
 >Re: Data, enumerateBytes: separate blocks? (From: Quincey Morris <email@hidden>)
 >Re: Data, enumerateBytes: separate blocks? (From: Daryle Walker <email@hidden>)
 >Re: Data, enumerateBytes: separate blocks? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Gamecenter not updating scores at the completion of submit
  • 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