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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:01:30+00:00 2026-06-09T18:01:30+00:00

I just started iOS programming and am failing to understand this.. I am trying

  • 0

I just started iOS programming and am failing to understand this.. I am trying to connect to a website that has a login.. I am using NSURLConnection and POST, and sending my login credentials..

The credentials are right and the connectionDidFinishLoading: is called but it is not completely logged into the site.. the login is partially complete..I identified this when I looked at the response.. As per my understanding the “connectionDidFinishLoading” is called only after the connection is complete.. I am definitely missing something here.. My code is below.. Please advice..

- (IBAction)connect:(id)sender {
    // Login to the website
    urlRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.mywebsite.com/login"]
                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                   timeoutInterval:60.0];

    NSString *post = @"username=myname&password=mypassword";
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

    [urlRequest setHTTPMethod:@"POST"];
    [urlRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [urlRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [urlRequest setHTTPBody:postData];

    // Start the connection request
    urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
}

Here, when I log the response, it is incomplete.. It is landing in a page that is between the final SUCCESS page.. So the authentication is partially complete..Do I need to include any delay? Please help..

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    NSLog(@"Connection success.");
    NSURLResponse *responseTest;
    NSError *error;

    NSData *responseDataTest = [NSURLConnection sendSynchronousRequest:urlRequest       returningResponse:&responseTest error:&error];

    NSString *responsestring = [[NSString alloc] initWithData:responseDataTest encoding:NSASCIIStringEncoding];
    NSLog(@"Recieved response.. %@",responsestring);
}

Thanks in advance..

  • 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-09T18:01:31+00:00Added an answer on June 9, 2026 at 6:01 pm
    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
    

    Try using this method instead. According to the docs it is “Sent when the connection has received sufficient data to construct the URL response for its request. (required)”

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

Sidebar

Related Questions

I've just started iOS drawing programming and I found out that the coordinate system
Just getting started with Obj-C and iOS programming. I have some code that loads
I've just started using the facebook-ios-SDK. I'm trying to run the sample app to
I just started with iOS programming recently, and assumed that I understood Objective-C reference
This question has been on my mind ever since I started with iOS development:
I´ve just started using ASIHTTPRequest for iOs and I have a small issue with
I have just started programming on iOS a couple of weeks ago, so sorry
I've just started writing tests for my iOS app, I'm using Xcode4 and OCUnit.
I just started iOS development am currently developing an application that just reads data
I just started with iOS development, so pardon if this is too simple I

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.