I am trying to send a file via Bluetooth using the GameKit framework. The problem I am having though is that I can only send one NSData object at a time, but I need to save it on the other end. this obviously isn’t possible without knowing the filename, but i don’t know how to transmit that. I’ve tried to convert it to a string NSData*data = [NSData dataWithContentsOfFile:urlAddress]; but i can only send one NSData object, not two.
Has anyone come across this problem yet?
Working with the GameKit for a while I’ve found that there is a limit of about 90k per ‘send’ so if you’re file is larger then 90k you’ll have to break it up. Here is how I would suggest you break things up:
1st – Send the name of your file
2nd – Send the number of chunks your going to send
3rd – Break up and send your NSData object into a set of NSObjects of less then 50k each (just to be on the safe size)
On the receiving side you’ll want to do the following:
1st – Receive the file name
2nd – Receive the number of chunks you are about to receive
3rd – Receive the chunks of data
If everything has worked right you will now have a
fileNameStrobject containing your file name and adataobject containing the contents of your file.Hope this helps – AYAL