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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:41:10+00:00 2026-06-07T04:41:10+00:00

I am trying to make a remote server call using this code: – (IBAction)login:(id)sender

  • 0

I am trying to make a remote server call using this code:

- (IBAction)login:(id)sender 
{    
    // Arguments are subject and body.
    NSString *urlString = @"my_url";

    NSString *email = self.email.text;
    NSString *password = self.password.text;


    NSString *url_to_send = [NSString stringWithFormat:urlString , email , password];;     

    NSString *escapedString = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
                                                                                  (__bridge CFStringRef)url_to_send,
                                                                                  NULL,
                                                                                  (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                                                  kCFStringEncodingUTF8);

    // Now send to the server    
    NSURL *url = [NSURL URLWithString:escapedString];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];

    // ***************
    // TODO: ok I dont really understand what this is
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    // **************

    [NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
     {                  
         NSLog(@"This is data: %@" , data);
         NSLog(@"This is response: %@" , response);
         NSLog(@"This is error: %@" , error);

         if ( error == nil )
         {
             // Display a message to the screen.
         }
         else
         if ([data length] > 0 && error == nil)
         {
                 // Do something
         }
         else 
         {
             // Do something else                         
         }
     }];    
}

if i don’t encode the URL, it actually comes back without an error. But if I encode the url, it gives this error:

This is data: (null)
2012-07-08 11:10:56.110 BusinessPlan[1630:14603] This is response: (null)
2012-07-08 11:10:56.111 BusinessPlan[1630:14603] This is error: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x684a180 {NSErrorFailingURLStringKey=My_encoded_url, NSErrorFailingURLKey=my_encoded_url, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x6895d00 "unsupported URL"}

What does this error mean? Did I encode it incorrectly? Also, when I don’t encode it, the data and response objects come back with values, but I wasn’t sure how to get those values from those objects. How do I tell what data is in those objectS?

Thanks!

  • 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-07T04:41:12+00:00Added an answer on June 7, 2026 at 4:41 am

    The problem is that you’re encoding the entire string, which includes the scheme and the URI elements. You probably just want to encode the query part of your URL.

    For example, if your URL were http://www.example.com/whatever?u=jason&p=pass.!!, you’d want to encode the query part but nothing else. The properly encoded URL for this example would look like:

    http://www.example.com/whatever?u=jason&p=pass%2E%21%21

    Since you’re just encoding the entire string, you’re ending up with this:

    http%3A%2F%2Fwww%2Eexample%2Ecom%2Fwhatever%3Fu%3Djason%26p%3Dpass%2E%21%21

    which is not a valid URL. Instead of escaping the entire string, just escape your query part. If your backend server can deal with it, you can build and escape the entire query string because only your server is going to parse that part. If it can’t deal with it for any reason, you’ll have to escape just the key and value parts of the query string.

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

Sidebar

Related Questions

I'm trying to make a class to handle invoking methods on a remote server
I'm trying to connect to a MySQL database on a remote server using MySQLdb
I have a Rails app and trying to make a remote form, so far
I'm trying make a login window where a user is prompted to enter their
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I'm using SimpleXMLElement to read xml returned from a remote server. The results are
I'm trying to send-retrive message from server by SOAP... but soapConnection.call( soapMessage, endpoint )
I am trying to make an HttpWebRequest from an ASP.Net page on a server
After wasting two days with this question (and trying to make it work), I've

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.