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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:40:13+00:00 2026-05-16T05:40:13+00:00

Inside ClassA: -(void)authenticateUser { authenticate_Obj = [classB_Obj authenticateMobileUser]; } Inside ClassB: -(AuthenticateObj*)authenticateMobileUser { [mobile_Obj

  • 0

Inside ClassA:

-(void)authenticateUser
{
   authenticate_Obj = [classB_Obj authenticateMobileUser];
}

Inside ClassB:

-(AuthenticateObj*)authenticateMobileUser
{
   [mobile_Obj AuthenticateMobileServer:self action:@selector(Handler:)];
   return authenticate_G_Obj;
}

-(void)Handler:(id)value
{
   authenticate_G_Obj = (AuthenticateObj*)value;
}

Now once the authenticateMobileUser method of classB returns the controll back to ClassA, we will get the Object authenticate_Obj initiated.

My problem is , when i run the project the authenticate_Obj is NULL… actually when it enters the handler method , the Object is initiallized. but the controlled is returned back to ClassA, without entering into Handler method. I guess this is the problem of Asynchronous execution.
How to make it enter into handler method and then only return the controll to ClassA??

Plz help me..

Thank You.

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

    It sounds like what you think you want to do is to block execution until authentication completes. This might be possible if AuthenticateMobileServer spawns a background thread to work in — you’d use a synchronisation object such as NSLock — but it’s really a Bad Idea. Why have a background thread at all if you’re going to block anyway? And thread synchronisation is notoriously tricky and prone to errors if you don’t know what you’re doing, which (let’s face it) you don’t.

    Instead, you probably should accept that there will be a period of uncertainty while the authentication takes place, during which your app should keep processing in some intermediate state, and then use a callback to notify you when the authentication is complete and you can then go on with whatever it is you need to do with the authenticated user.

    There are a bunch of ways you could do this, and there’s not enough detail in the question to say exactly which would be best. But you already seem to be using something very similar within ClassB, so I’d say do the same from ClassA:

    Inside ClassA:
    
    -(void)authenticateUser
    {
       authenticate_Obj = nil;
       [classB_Obj authenticateMobileUserAndNotify:self action:@selector(authenticatedObject:)];
       // returns more or less immediately, not yet authenticated
    }
    
    -(void)authenticatedObject:(YourAuthObjectClass*) authObj
    {
        authenticate_Obj = authObj;
        // do post-authentication stuff here
    }
    
    Inside ClassB:
    
    -(void)authenticateMobileUserAndNotify:(id)target action:(SEL)sel
    {
       // I'm making these ivars for simplicity, there might be other considerations though
       callbackTarget = target;
       callbackSelector = sel;
    
       [mobile_Obj AuthenticateMobileServer:self action:@selector(Handler:)];
    }
    
    -(void)Handler:(id)value
    {
       authenticate_G_Obj = (AuthenticateObj*)value;
       [callbackTarget performSelectorOnMainThread:callbackSelector withObject:authenticate_G_Obj waitUntilDone:NO];
    }
    

    Obviously this is just a sketch and not intended to be used as is. And you’ll need to consider what goes on in your app while in the waiting state, with authentication in progress but authenticate_Obj still nil. But hopefully you get the idea.

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

Sidebar

Related Questions

I want to call a method of my class inside a lambda expression: void
I have 2 classes. A and B. Inside ClassA I have a method which
public ClassA { private String firstId; private String secondId; public void setFirstId(String firstId) {
I have this method inside an Activity which implements an ImageLoader class: public void
I have a static method like follows public static void foo(){ final ClassA a
Consider the following code: @interface ClassA : NSObject @property (nonatomic, copy) void(^blockCopy)(); @end @implementation
There are two ways to overload operators for a C++ class: Inside class class
In PHP, What is the difference between declaring methods inside class like public function
At the moment inside the class I have ArrayList which the objects are stored
I can extend an inner class/trait inside the outer class or inside a class

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.