tags:

views:

48

answers:

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?

+1  A: 

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
I don't suppose anyone know how to break up data in to packets?
Burf2000
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