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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:08:10+00:00 2026-05-22T12:08:10+00:00

I have an Authenticator class which has a method to authenticate with an API

  • 0

I have an Authenticator class which has a method to authenticate with an API key and another method to authenticate with an email address and password. Authentication is done with an async HTTP request.

I have a LoginController that is managing the view that the user will enter their email/password into.

Here’s a code snippet:

// LoginController

- (void)awakeFromNib {
   self.authenticator = [[Authenticator alloc] init];
}

- (IBAction)authenticateWithEmailAndPassword: (id)sender {
    // Async HTTP request, so we can't just check the return 
    // value to see if authentication was successful or not
    [self.authenticator authenticateWithEmail:[emailField stringValue]
                                     password:[passwordField stringValue]];
}

My Authenticator object does the authentication, and my LoginController needs the asynchronous result (success or failure).

What’s the Objective C way of communicating asynchronously from the model back to the controller?

  • 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-22T12:08:10+00:00Added an answer on May 22, 2026 at 12:08 pm

    One possible pattern you could use here would be a delegate.

    You could define a AuthenticatorDelegate protocol and have your LoginController conform to it. Something like:

    @protocol AuthenticatorDelegate
    - (void) authenticationSuccessful;
    - (void) authenticationFailedWithError:(NSError *)error
    @end
    
    @interface Authenticator : NSObject
    {
        ...
        id <AuthenticatorDelegate> delegate;
    }
    @property (assign) id <AuthenticatorDelegate> delegate;
    
    @end
    

    your LoginController would be declared as

    @interface LoginController : UIViewController <AuthenticatorDelegate>
    ...
    

    and when you initialize it you set the delegate

    - (void)awakeFromNib {
        self.authenticator = [[Authenticator alloc] init];
        self.authenticator.delegate = self;
    }
    

    and then when your Authenticator objects receive the result you just call the appropriate method on the delegate.

    Of course that’s just one of the possibilities. Other approaches could use code blocks or a target/selector pair.

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

Sidebar

Related Questions

I have a login page where I authenticate the user. When the authentication pass,
Here's a scenario: I have a java front end (RCP/SWT) app which currently has
I'm attempting to use the Super Inplace Controls plugin, which has an in_place_select method.
I have a .Net 3.5 website which uses windows authentication and expires the session
I have authentication mode set to forms in my asp.net web.config but am still
I'd like to setup Tomcat on Windows and have authentication in my web application
I have an authentication script ( CheckLogin.aspx ), and if any of the credentials
I have implemented authentication systems for webapps several times over the years, but before
I would like to have the authentication and registration parts of my website encrypted
I have a site that requires Windows Authentication the application obtains the credential from

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.