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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:37:09+00:00 2026-06-14T04:37:09+00:00

Here is my code: //login method – (int) authenticateClient { NSString *loginWeb = [NSString

  • 0

Here is my code:

//login method
- (int) authenticateClient {
NSString *loginWeb = [NSString stringWithFormat:(@"http://192.168.118.1/login.php?uname=%@&pass=%@&submit=Log%%20In"), user, pass];
NSURL *login = [NSURL URLWithString:loginWeb];
NSData *loginData = [NSData dataWithContentsOfURL: login];
NSString *result = [[NSString alloc] initWithData:loginData encoding:NSUTF8StringEncoding];
NSMutableURLRequest *loginRequest = [[NSMutableURLRequest alloc] init];
[loginRequest setURL:login];
[loginRequest setTimeoutInterval:1];

NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:loginRequest delegate:self startImmediately:YES];
[connection start];
   return [result integerValue];
}

My question is, when simulating having no network connection, my app freezes up and doesn’t load or time out in the specified interval (1 second just to see if it works).

I read something about start immediately forces in to run on the current threat causing everything else to “pause” until the action is complete.

I have two questions:

1.) What is a better method to have the URL basically run in the background instead of pausing everything?

2.) How can I get a timeout method that actually works?

Much appreciation! 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-14T04:37:10+00:00Added an answer on June 14, 2026 at 4:37 am

    Well, one second as timeout is really low. If you want to simulate different network conditions, you can use something like this. You don’t need to this dance:

    NSData *loginData = [NSData dataWithContentsOfURL: login];
    NSString *result = [[NSString alloc] initWithData:loginData encoding:NSUTF8StringEncoding];
    

    You don’t need this as well, since the connection has started already:

    [connection start];
    

    Also from the documentation:

    NSURLConnection’s delegate methods—defined by the
    NSURLConnectionDelegate Protocol protocol—allow an object to receive
    informational callbacks about the asynchronous load of a URL request.
    Other delegate methods provide facilities that allow the delegate to
    customize the process of performing an asynchronous URL load. These
    delegate methods are called on the thread that started the
    asynchronous load operation for the associated NSURLConnection object.

    So for your questions:

    • Implement the NSURLConnection’s delegate
    • Check this & this.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
Basically here is my code (Authenticator.jsp): window.location.replace(Login.html); // replace method also takes care of
Here my code, I need to insert into mysql database I have mysql,php,android 1)
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
Here is code example class A{ int i; public: A(int i) : i(i) {}
I am trying to run the code here -- http://code.google.com/p/android-market-api/wiki/HowDownloadApps --, and have this
i have web service in php which contain method (login) that should return false
I have below code.The logic here is if HostList conatains any blanck entry it
The script is on jsfiddle here : CODE What it does at the moment
Ok the error is showing up somewhere in this here code if($error==false) { $query

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.