Burf2000
Burf2000

Reputation: 5193

Why does my application crash when sending data via Game Kit?

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?

Upvotes: 1

Views: 421

Answers (1)

skram
skram

Reputation: 5314

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.

Upvotes: 2

Related Questions