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 6905913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:14:32+00:00 2026-05-27T08:14:32+00:00

I have implemented a client-server transferring from Windows desktop application to iPhone App. I

  • 0

I have implemented a client-server transferring from Windows desktop application to iPhone App. I transfer data in a different format but always as a string using NSStream polling mode:

    if([inputStream hasBytesAvailable]) {
        len = [inputStream read:buffer maxLength:sizeof(buffer)];
        if (len > 0) {
            NSString *output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding];
            if (nil != output) {
                [_arrRisposta addObject:output];
                _strRisposta = [NSMutableString stringWithString: output];
            }
        }
        else {
            break;
        }
    }

Everything works perfectly, but when I transfer a PDF file and save it, the file is not the same. When I load the file in UIWebView the number of pages is correct but there is no content. I save the file like this:

                NSFileManager *fileManager = [NSFileManager defaultManager];
                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                NSString *docDir = [paths objectAtIndex:0];
                NSString *dataFile = [docDir stringByAppendingPathComponent:[NSString stringWithFormat:@"temp.%@", @"pdf"]];

                if ([fileManager fileExistsAtPath:dataFile]) {
                    [fileManager removeItemAtPath:dataFile error:nil];
                }
                [_strContenuto writeToFile:dataFile atomically:YES encoding:NSUTF8StringEncoding error:nil];

                NSURL *fileUrl = [NSURL fileURLWithPath:dataFile];
                [webModello loadRequest:[NSURLRequest requestWithURL:fileUrl]];

What’s wrong? I tried to change the encoding of the string but I have not solved. If I compare the transferred file with the original, there are some characters that do not match.
Could someone help me, please?

  • 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-27T08:14:33+00:00Added an answer on May 27, 2026 at 8:14 am

    You should not use strings. Change your code to use NSData objects. PDF files are not strings, and there are all sorts of encoding issues you would have to worry about to get this working with strings (if it ever would).

    I have not looked up the exact api usage for NSData, this is all from my head… so don’t go copy and pasting this!

    // Somewhere in your code
     _myData = [[NSMutableData alloc] init];
    
    // when data comes in....
    
     if([inputStream hasBytesAvailable]) {
        len = [inputStream read:buffer maxLength:sizeof(buffer)];
        if (len > 0) {
               [_myData addBytes:buffer length:len];
            }
        }
        else {
            break;
        }
    }
    
    // when the callback comes in saying all data  there:
     [_myData writeToFile:@"path/topdf/file.pdf" atomically:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a client-server transferring from Windows desktop application to iPhone App. I
I have a client server based windows forms application that needs an administrator only
I have implemented a web service with server and client authentication using keytool. The
I have developed a Flash application for a client (wedding RSVP) and implemented it
I have implemented a simple server-client script like this: Server: class Server(Protocol): def connectionMade(self):
I have a server client application. The clients sends the server http posts with
I have created a server/client application. Both of them are written in C#. It
I have implemented the client server using socket programming in C on Unix OS.
I need to implemented security for client-server communication. I have implemented the following hybrid
I have implemented a Kerberos server/client using sockets in Java, where the client sends

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.