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

  • Home
  • SEARCH
  • 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 8512433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:16:46+00:00 2026-06-11T04:16:46+00:00

-(void)loadRequest:(NSString *)jsonString{ receivedData = [[NSMutableData alloc]init]; urlString = [[NSString alloc]initWithString:[NSString stringWithFormat:kURL]]; urlRequest=[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

  • 0
-(void)loadRequest:(NSString *)jsonString{
receivedData = [[NSMutableData alloc]init];
urlString = [[NSString alloc]initWithString:[NSString stringWithFormat:kURL]];
urlRequest=[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
   requestInformation =[[NSMutableURLRequest alloc]initWithURL:urlRequest cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
[requestInformation setValue:khttpValue forHTTPHeaderField:kContentType];
[requestInformation setValue:@"value1" forHTTPHeaderField:@"key1"];

[requestInformation setHTTPMethod:kPost];
jsonData= [[NSString stringWithFormat:@"json=%@",jsonString] dataUsingEncoding:NSUTF8StringEncoding];
[requestInformation setHTTPBody:jsonData];

connection = [[NSURLConnection alloc] initWithRequest:requestInformation delegate:self];
[connection start];
if(connection){
    NSLog(@"Connection succesfull");
}
else{
    NSLog(@"There is a error in connection");
    [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(onFailedToUpload) userInfo:nil repeats:NO];

}
}

how to check if the else part is executed. I give incorrect URL , didfailwitherror method is called but the else part is not executed.

  • 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-11T04:16:48+00:00Added an answer on June 11, 2026 at 4:16 am

    As far as I know, the connection object is always created. Even of your url is wrong. Any errors whatsoever comes to the delegate didFailWithError method. You probably need to examine the error & proceed appropriately. Ex. In case it is a timeout you might want to retry in didFailWithError delegate. For other error types handle differently.

    If you want to handle broken or bad urls before passing it to NSURLConnection then you need to do that yourself.

    Here are the delegates which are of use to you when using NSURLConnection –

    - (void)connection:(NSURLConnection *)connection
    didReceiveResponse:(NSURLResponse *)response 
    {
        NSLog("@Resp received");
        return;
    }
    
    - (void)connection:(NSURLConnection *)connection
        didReceiveData:(NSData *)data 
    {
        NSLog("@Data received");
        return
    }
    
    - (void)connection:(NSURLConnection *)connection
      didFailWithError:(NSError *)error 
    {
        NSLog("@ERROR: Achtung !: %@",[error localizedDescription]);
    }
    
    - (void)connectionDidFinishLoading:(NSURLConnection *)connection 
    {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH , 0),, ^{
            NSLog(@"FinishedLoading: In bg thread, do something with data here");
    
            dispatch_async( dispatch_get_main_queue(), ^{
                NSLog(@"FinishedLoading: In Main thread, access the UI here");
            });
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

-(void)loadWebAdress:(NSString*)textAdress { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; adressurl=[NSString stringWithFormat:@http://%@, textAdress]; NSURL *url=[NSURL URLWithString:adressurl]; NSURLRequest *requestObj=[NSURLRequest
- (void)viewDidLoad{ [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@VidName ofType:@mov]; NSURL *url =
-(IBAction)click; { NSURL *url = [NSURL URLWithString:URL_TO_DOWNLOAD]; NSString *tempDownloadPath = [[self documentsDirectory] stringByAppendingPathComponent:@test.pdf]; ASIHTTPRequest
I'd like to use UIWebView's - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL but I'm not sure
- (void)fadeOutSplash { UIImageView *splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@Default-Landscape~ipad.png]]; [self.window.rootViewController.view addSubview:splash]; // <--
I am loading request like this [resultsWebView loadRequest:searchRequest]; Then I do this - (void)
This is my code: -(void)viewDidLoad { [super viewDidLoad]; NSString *indexPath = [NSBundle pathForResource:@iHelp ofType:@html
- (IBAction)saveButton:(id)sender { NSURL *yourURL = [NSURL URLWithString: webpageURLLabel.text ]; NSURLRequest *request = [[NSURLRequest
I'm using this code to display an image in an UIWebView: -(void)showImageWithLoadRequest{ NSString *path
void test() { unsigned char c; c = (~0)>>1 ; printf(c is %u\n,c); }

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.