Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 824157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:03:32+00:00 2026-05-15T03:03:32+00:00

I am trying to send a file via Bluetooth using the GameKit framework. The

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:03:33+00:00Added an answer on May 15, 2026 at 3:03 am

    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

    NSData* fileNameData = [fileNameStr dataUsingEncoding: NSASCIIStringEncoding];
    // send 'fileNameData'
    

    2nd – Send the number of chunks your going to send

    NSUInteger fiftyK = 51200;
    NSUInteger chunkCount = (((NSUInteger)(srcData.length / fiftyK)) + ((srcData.length % fiftyK) == 0 ) ? 0 : 1))
    NSString chunkCountStr = [NSString stringWithFormat:@"%d",chunkCount];
    NSData* chunkCountData = [chunkCountStr dataUsingEncoding: NSASCIIStringEncoding];
    // send 'chunkCountData'
    

    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)

    NSData *dataToSend;
    NSRange range = {0, 0};
    for(NSUInteger i=0;i<srcData.length;i+=fiftyK){
      range = {i,fiftyK};
      dataToSend = [srcData subdataWithRange:range];
      //send 'dataToSend'  
    }
    NSUInteger remainder = (srcData.length % fiftyK);
    if (remainder != 0){
      range = {srcData.length - remainder,remainder};
      dataToSend = [srcData subdataWithRange:range];
      //send 'dataToSend'  
    }
    

    On the receiving side you’ll want to do the following:

    1st – Receive the file name

    // Receive data
    NSString* fileNameStr = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]
    

    2nd – Receive the number of chunks you are about to receive

    // Receive data
    NSString* chunkCountStr = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]
    NSUInteger chunkCount = [chunkCount intValue];
    

    3rd – Receive the chunks of data

    NSMutableData data = [[NSMutableData alloc]init];
    for (NSUInteger i=0; i<chunkCount;i++){
      // Receive data
      [data appendData:receivedData];
    }
    

    If everything has worked right you will now have a fileNameStr object containing your file name and a data object containing the contents of your file.

    Hope this helps – AYAL

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to send a Docx file via this form that I made, the
I'm trying to send a file via Zend Framework's (1.10.7) Mail library. $mail =
I am trying to send the device log file via email and using the
I'm trying to send a file using POST in multipart/form data via Indy 10.5.8.
I'm trying to send a file base64-encoded via apache.commons.mail and I just can't seam
I've been trying to send a file to an ftp server via an FTPClient
I'm trying to send a file to the browser to download, and not having
I am trying to send a file to the browser in a Zend Framework
am trying send an array to php file using $_POST ,still always getting an
I'm trying to send form fields and file to a web service using php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.