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

  • SEARCH
  • Home
  • 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 7788855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:06:35+00:00 2026-06-01T21:06:35+00:00

On Iphone as well as android I am getting response codes of 200 meaning

  • 0

On Iphone as well as android I am getting response codes of 200 meaning that I am getting a valid and good response with no errors, but the json that I am receiving has additional characters. I print out the NSData that I receive and it is 580 in length and the NSString, at least when it fails, will have a larger length and print n+ extra characters on the end of the json. I am not sure why this would be but thought I would see if anyone can see what I would be doing incorrectly.

NSString *post = [NSString stringWithFormat:@"referer=%@&username=%@&password=%@", referer, username, password];
NSData *pData = [post dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion:YES];
NSString *pLength = [NSString stringWithFormat:@"%d", [pData length]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
    [request setURL:self.url];
    [request setHTTPMethod:@"POST"];
    [request setValue:pLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:pData];
    [request setTimeoutInterval:30];

NSHTTPURLResponse *response = nil;
    NSError *err = nil;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
    NSString *sData = [NSString stringWithUTF8String:[data bytes]];

I do not receive any errors and every response code that I receive is 200. I have printed out all of these values as well. data length is 580 and sData will vary at times but when it does pass it will be 580 in length, but this can change for different cases. The data will not always be 580 for other users that use the system.

ANSWER:

I solved the problem instead of using

NSString *sData = [NSString stringWithUTF8String:[data bytes]];

You should use

NSString *sData = [[NSString alloc] initWithData: data encoding: NSUTF8String];

This will alloc the correct amount of space based on the NSData object and thus the NSString will never try to access or store more space in that may be behind the last address that should have been accessed.

  • 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-06-01T21:06:38+00:00Added an answer on June 1, 2026 at 9:06 pm

    ANSWER:

    I solved the problem instead of using

    NSString *sData = [NSString stringWithUTF8String:[data bytes]];
    You should use

    NSString *sData = [[NSString alloc] initWithData: data encoding: NSUTF8String];
    This will alloc the correct amount of space based on the NSData object and thus the NSString will never try to access or store more space in that may be behind the last address that should have been accessed.

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

Sidebar

Related Questions

Have any well-documented or open source projects targeted iPhone , Blackberry , and Android
What are some iPhone or Android applications that use SMS as their primary means
I have a PhoneGap app that I'm testing on webOS, Android, and iPhone. I'm
I have a site that is mostly designed for viewing on Android and iPhone
I'm working on a project for iphone and android browsers that requires that I
we have an app which is available for ipad, iphone, android as well as
I'm designing an application that will target android and iphone at the same time.
I have a running JQueryMobile App that Im developing with PhoneGap for Android/IPhone, and
Is it possible to install the beta iPhone SDK as well as the latest
I have a script working well for creating ad hoc iPhone builds. I can

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.