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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:00:18+00:00 2026-05-19T05:00:18+00:00

In my iPhone app, I need to access the webserver to login into my

  • 0

In my iPhone app, I need to access the webserver to login into my system. The client requires that the database be on server only. So I have made an admin panel in ASP.NET and MySQL database where in I store the login information.

Now when I use the method given below in the code to fetch the data from server then it takes too much of time (i.e. More than a minute.) to respond.

In the case where I have fetched a particular data from server before, then that value is fetched fast when I try to fetch it the next time. But for new data it again takes lots of time or rather times out.

Sometimes the request even times out.

What should I do to decrease the delay and speed up the whole login process?

Is there a better way to do this?

Info regarding Code below:

firstname.text is my Username.

lastname.text is my Password.

label.text is a temporary label that I use to store the password obtained from server.

allUsers is the array where the response obtained from server is stored.

Also I am using JSON to parse the data between webserver and iPhone.

I use a plist to store my url. Plist name is url.plist.

Code is as Below:

    SBJSON *json = [SBJSON new];
    json.humanReadable = YES;
    NSString *service = @"/getUserInfo";
    //NSString *requestString = [NSString stringWithFormat:@"{\"method\":\"%@\"}",  service];
    NSString *requestString = [NSString stringWithFormat:@"{\"firstname\":\"%@\"}",firstName.text,nil];
    NSLog(@"Request String: %@", requestString);

    NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];

    NSString *fileLoc = [[NSBundle mainBundle] pathForResource:@"url" ofType:@"plist" ];
    NSDictionary *fileContents = [[NSDictionary alloc] initWithContentsOfFile:fileLoc];
    NSString *urlLoc = [fileContents objectForKey:@"baseURL"];
    urlLoc = [urlLoc stringByAppendingString:service];
    NSLog(@"URL is %@",urlLoc);
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: 
                                    [NSURL URLWithString: urlLoc]];  

    NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]];
    [request setHTTPMethod: @"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody: requestData];

    //Data returned by WebService
    NSError *respError = nil; 
    NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: &respError ];

    if (respError) {
        NSString *msg = [NSString stringWithFormat:@"Connection failed! Error - %@ %@",
                         [respError localizedDescription],
                         [[respError userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]];   

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Check your network connection" 
                                                            message:msg delegate:self cancelButtonTitle:@"OK" 
                                                  otherButtonTitles:nil];
        [alertView show];


        NSArray *keys = [NSArray arrayWithObjects:@"firstname", @"lastname", nil];
        NSArray *objects = [NSArray arrayWithObjects:@"failed to", @"refresh data...", nil];
        NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];

        allUsers = [[NSArray alloc] initWithObjects:dictionary, nil];
        //[self setUserData:allUsers];
        //[tblView reloadData];

        //[allUsers release];

    } 
    else
    {

        NSString *responseString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];

        NSDictionary *results = [responseString JSONValue];
        // Additional steps as the webservice is adding an additional "{d:" so stripping of that
        NSString *extractUsers = [results objectForKey:@"d"];

        // The actual string that Web services returned, so re-scan the same and convert it as object
        NSDictionary *finalResult = [extractUsers JSONValue];
        allUsers = [finalResult objectForKey:@"users"];
        NSLog(@"Data is : %@",allUsers);
        NSLog(@"Final Value is : %@",[[allUsers objectAtIndex:0] valueForKey:@"lastname"]);
        if([allUsers count]>0)
        {
            label.text = [[allUsers objectAtIndex:0] valueForKey:@"lastname"];
        }
        else 
        {
            label.text = @"";
        }
        [responseString release];
        [request release];

    }




    [inProgressIndicator stopAnimating];
    [fileContents release];

    //Release all the allocated data
    [json release];

}
  • 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-19T05:00:19+00:00Added an answer on May 19, 2026 at 5:00 am

    At first, you should check on which side delay is taking place – is it server’s lag (maybe, not optimized DB usage or so on), internet-connection issue or another problem.
    Just trace and check, which line of code is executed for that minute at first.

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

Sidebar

Related Questions

I need in a iPhone app to access files that the app is build
In my iPhone app, I need to access the SMS application. I need that
I am building an iPhone app that will need to display info primarily in
I need to have a few buttons in my iPhone app (which may be
I have a simple iPhone app that Im learning and I want to have
Let's say I need to access a web service from an iPhone app. This
I am developing a iPhone app using Monotouch. I need to access a Sqlite
I'm making an iphone app. All you need to know is that there is
I'm trying to access a website using my login credentials through an iPhone app
I have an iPhone app that is using sqlite 3.6 (not with FMDB) to

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.