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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:12:24+00:00 2026-05-31T05:12:24+00:00

Using below code I am trying to get result which should be like success

  • 0

Using below code I am trying to get result which should be like success or something else. But In my result value I am getting nothing, its blank.

What can be the issue?

- (IBAction)login:(id)sender {

    NSString *user = [userName stringValue];
    NSString *passwd = [passwordField stringValue];

    NSLog(@"username:::password::: %@ %@", user, passwd);


    NSURL *url = [NSURL URLWithString:@"http://myurl.html?userName=%@&userPassword=%@"];

    NSError *myError = nil;

    // create a plaintext string in the format username:password
    NSMutableString *loginString = (NSMutableString*)[@"" stringByAppendingFormat:@"%@:%@", user, passwd];

    NSString* encodedString = [[loginString dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString];

    // create the contents of the header 
    NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", encodedString];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url
                                                           cachePolicy: NSURLRequestReloadIgnoringCacheData  
                                                       timeoutInterval: 3];   

    [request setHTTPMethod:@"POST"];

    // add the header to the request.  Here's the $$$!!!
  //  [request addValue:authHeader forHTTPHeaderField:@"Authorization"];

    [request addValue:user forHTTPHeaderField:@"userName" ];
    [request addValue:passwd forHTTPHeaderField:@"userPassword" ];

    // perform the reqeust
    NSURLResponse *response;

    NSData *data = [NSURLConnection  
                    sendSynchronousRequest: request  
                    returningResponse: &response  
                    error: &myError];  
  //  *error = myError;

    //the content of the webserver's response.
    NSString *result = [NSString stringWithCString:[data bytes] length:[data length]];

    NSLog(@"result: %@", result);

}

Any help 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-31T05:12:24+00:00Added an answer on May 31, 2026 at 5:12 am

    For your URL:

    NSURL *url = [NSURL URLWithString:@"http://myurl.html?userName=%@&userPassword=%@"];
    

    This is not correct.

    dont you need to add here the user and password? Something like:

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://myurl.html?userName=%@&userPassword=%@", user, passwd];
    

    And.. why are you creating the strings like that? Instead of:

    NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@", encodedString];
    

    You should do:

    NSString *authHeader =[NSString stringWithFormat:@"Basic %@", encodedString];
    

    I really think your problem is in the strings you are creating, check all of them

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

Sidebar

Related Questions

I am trying to change desktop image using below code: NSError *anError = nil;
I am trying to load a JS file using yepnope using the below code:
I am trying to retrieve information through Facebook graph api, using the below code
I'm trying to create a custom drop down and using the code below it
I'm trying to draw the pages of a PDF using the code below. Some
I am trying to access an SQLite 3 database programmatically using the code below:
Afternoon all, Using the code below I'm trying to load what is render by
Im trying to generate a color gradient using ColdFusion. My current code below works
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
I'm trying to figure something that is going on with my Route-Me code using

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.