• 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: Wanted: Elegant way to manage this task
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wanted: Elegant way to manage this task


  • Subject: Re: Wanted: Elegant way to manage this task
  • From: Greg Parker <email@hidden>
  • Date: Tue, 09 Jun 2015 00:26:37 -0700

> On Jun 8, 2015, at 11:47 PM, Roland King <email@hidden> wrote:
>
> Without answering 98.7% of your question, or more. Are you wedded to NSData for this? I have a stream processor, it takes randomly chunked up data from a bluetooth dongle and .. processes it. I used dispatch_data_t for it. That was introduced back with GCD a few years ago. It’s proved very good for this kind of data manipulation. You can append them to each other, split them into pieces, iterate over them but under the hood all the while it keeps the original chunks of data and avoids a lot of copying around. Only if you at some point want N contiguous bytes out of the thing to process as a byte array will it do a copy if necessary into one single memory chunk, if the piece you want is already in one chunk, it just returns it to you. I’ve found it a good way to deal with buffers of bytes very efficiently and quite intuitively.

Note that a dispatch_data_t can be used as an NSData object (but not vice versa) as of iOS 7 and OS X 10.9. That means you can use dispatch_data_t to collect chunks as they arrive, then pass the result to a consumer that wants NSData. If all goes well you'll get NSData compatibility with zero or one extra copies.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

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


References: 
 >Wanted: Elegant way to manage this task (From: Graham Cox <email@hidden>)
 >Re: Wanted: Elegant way to manage this task (From: Roland King <email@hidden>)

  • Prev by Date: Re: Wanted: Elegant way to manage this task
  • Next by Date: Strange Warning Message from the Analyzer?
  • Previous by thread: Re: Wanted: Elegant way to manage this task
  • Next by thread: Re: Wanted: Elegant way to manage this task
  • Index(es):
    • Date
    • Thread