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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:23:23+00:00 2026-06-03T13:23:23+00:00

I have a custom UIViewController shown with presentModalViewController function in a http basic authentication

  • 0

I have a custom UIViewController shown with presentModalViewController function in a http basic authentication delegate to get username and password. I want to wait till the user clicked the login button on the modal view controller shown on the screen. How can I do this? I am new to iOS any comments or links would be appreciated.

Edit : here is a sample code inside NSURLConnectionDelegate

-(void) connection(NSURLConnection*)connection willSendRequestForAuthenticationChallenge(NSURLAuthenticationChallenge*)challenge
{
    CustomAuthViewController *authView = [CustomAuthViewController alloc] initWithNibName"@"CustomAuthViewController" bundle:[NSBundle mainBundle]];
    [parentcontroller presentModalViewController:authView animated:YES];
    // 
    // I want to wait here somehow till the user enters the username/password
    //
    [[challenge sender] userCredentials:credentials forAuthenticationChallenge:challenge];
}

Kind regards.

Edit : Solution : It is not necessary to send the credentials in the willSendRequestForAuthenticationChallenge delegate function right away. I can send it anytime later, It is strange though.

  • 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-03T13:23:26+00:00Added an answer on June 3, 2026 at 1:23 pm

    Basically what you want is to pass a message from the modal UIViewController to the caller when your login dialog completes. There are a number of ways to do this. Here’s a couple:

    Option 1 – Delegate Pattern:

    On your modal dialog .h

    @protocol LoginDelegate
    - (void)loginComplete:(NSString *)userId;
    - (void)loginFailed;
    @end
    
    @interface MyLoginDialog : UIViewController {
        UIViewController *delegate;
    }
    
    @property (nonatomic, retain) UIViewController *delegate;
    

    On your modal dialog .m

    in your init:

    delegate = nil;
    

    in your dealloc:

    [delegate release];
    

    when you complete your login:

    [delegate dismissModalViewControllerAnimated:YES]; 
    [delegate loginComplete:userId] or [delegate loginFailed];
    

    Then on your calling view controller implement the LoginDelegate protocol.

    And when you create your login view controller, set the delegate:

    UIViewController *viewLogin = [[UIViewController alloc] init];
    viewLogin.delegate = self;
    

    Option 2 – Post a notification with NSNotificationCenter:

    On your login dialog:

    [self dismissModalViewControllerAnimated:YES];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"LoginComplete" object:nil];
    

    On your calling view controller

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginComplete:) name:@"LoginComplete" object:nil];
    

    Then you implement the selector loginComplete.

    If you want to pass back login information (username, userId, etc) you can package that into a dictionary and add it as the “object” in the postNotificationName method.

    You also need to be sure to call

    [[NSNotificationCenter defaultCenter] removeObserver:self];  
    

    when you are done listening.

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

Sidebar

Related Questions

I have a custom UIViewController in a UITabbarController and want to respond to rotation
I have a few custom UITableViewCells - http://img11.imageshack.us/i/customfacilitiescell.png/ which are added to this UIViewController
I have a custom UIViewController in Interface Builder (in my storyboard) and I want
I'm trying to have a custom UIViewController class get popped to the navigation controller,
I have a custom UIViewController subclass and I want to override the loadView method.
I have a custom UIViewController subclass which acts as Datasource and Delegate for a
I have a custom UIViewController subclass, which gets pushed on a UINavigationController stack. I
I have a custom UIViewController, which is the only subView of UIView. The UIViewController
I have a custom UIViewController subclass that handles all the view initialization by itself
I have custom classes that I currently instantiate within App.xaml as resources. I want

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.