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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:21:09+00:00 2026-05-23T13:21:09+00:00

I have a simple POST coming from my iphone app. Its working fine, except

  • 0

I have a simple POST coming from my iphone app. Its working fine, except passing an ampersand causes the backend to break – it’s almost like its treating it like a GET request (ampersands seperate the variable names). Do I need to do some kind of encoding first? Here is the code:

NSString *content = [[NSString alloc] initWithFormat:@"data=%@&email=%@", str, emailAddress.text];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.myurl.com/myscript.php"]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[content dataUsingEncoding:NSISOLatin1StringEncoding]];

// generates an autoreleased NSURLConnection
[NSURLConnection connectionWithRequest:request delegate:self];
  • 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-23T13:21:09+00:00Added an answer on May 23, 2026 at 1:21 pm

    Edit: As stringByAddingPercentEscapesUsingEncoding: should be used to encode parts of the query, not the whole one, you should be using another method instead.

    Unfortunately, Foundation doesn’t provide such a method, so you need to reach to CoreFoundation:

    - (NSString *)stringByURLEncodingString:(NSString *)string {
        return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(
            kCFAllocatorDefault,
            (__bridge CFStringRef)string,
            NULL, // or (__bridge CFStringRef)(@"[].")
            (__bridge CFStringRef)(@":/?&=;+!@#$()',*"),
            kCFStringEncodingUTF8
        );
    }
    

    You can use

    - stringByAddingPercentEscapesUsingEncoding:
    

    In your case it will look like this:

    NSString * content = [[NSString alloc] initWithFormat:@"data=%@&email=%@", [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [emailAddress.text  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    

    You can do this in this way, too:

    NSString *dataStr = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *emailStr = [emailAddress.text  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSString *content = [[NSString alloc] initWithFormat:@"data=%@&email=%@", dataStr, emailStr];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ASP.NET MVC 3 dummy app (just learning MVC coming from
I have a simple form that looks like so <% remote_form_for post, :url =>
I have simple regex \.*\ for me its says select everything between and ,
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple SSIS package which reads data from flat file and insert into
I have a simple RSS feed coming in my Wordpress site with php, but
Good Morning, I have a really simple script that works fine on everything but
I am new to MVC3 and coming from a Winforms background. I have a
I'm new to Struts2, coming from a PHP background, where I'd often have the
Just a quick query really, In my PHP file, I have variables coming from

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.