1

I have been following this great guide on setting up bluetooth between 2 iPhones.

However, what I need to do is send binary (for instance a video) instead of text.

I load the data in to a NSData

localData = [NSData dataWithContentsOfFile:videoPath];

Then a few methods on send it

[self.gameSession sendDataToAllPeers:localData 
                                   withDataMode:GKSendDataReliable 
                                          error:nil];

But my application crashes. Do I need to encode it?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Burf2000
  • 5,001
  • 14
  • 58
  • 117

1 Answers1

2

As quoted from the GameKit Documentation, "For best performance, it is recommended that the size of the data objects be kept small (under 1000 bytes in length). Larger messages (up to 95 kilobytes) may need to be split into smaller chunks and reassembled at the destination, incurring additional latency and overhead." I would assume, you're trying to transfer a video. You would need to break this up in chunks and send in pieces to be put back together on the other side.

skram
  • 5,314
  • 1
  • 22
  • 26
  • I don't suppose anyone know how to break up data in to packets? – Burf2000 Aug 23 '10 at 07:46
  • Theres another Stack Overflow regarding this issue, http://stackoverflow.com/questions/2899020/split-nsdata-objects-into-other-nsdata-objects-with-a-given-size . Ive used it in an app, with some minor tweaks. – skram Aug 25 '10 at 05:56