spentak
spentak

Reputation: 4727

Break up NSData into byte packets to send to another device

1)How can I break up an NSData into chunks?

I want to iterate through the NSData and send each chunk via sendData GameKit.

2)The data that is being sent is an MP3. When the first chunk comes in, I want to convert it back to an MP3, start playing that file, then keep appending the remaining audio to it. How do I?

Upvotes: 1

Views: 1040

Answers (1)

Jeff Wolski
Jeff Wolski

Reputation: 6372

For the first the first part of your question...

You can break it up using the getBytes:length: and getBytes:range: instance methods.

Check the reference here.

For the second part of your question...

Use appendData. Of course this method for a NSMutableData. Find the reference here

Upvotes: 4

Related Questions