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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:36:22+00:00 2026-05-17T00:36:22+00:00

I am working on a class A which has a method -(void)DoSmthing1. I am

  • 0

I am working on a class A which has a method -(void)DoSmthing1. I am making a call to
another method-(void)DoSmthing2 in class B. Now after doing some operations in class B, the method is supposed to call back a method-(void)DoSmthing3 previous class.

How will i call a method of current class from another class?? Can someone please help me….

Thanks in advance

edit1::
My Code:
Class A

{
-(void) MethodA {

}

-(void) MethodB {
   ClassB *clsB = [[ClassB alloc] init];
   [clsB MethodC];
}  
}  

Class B

{
  -(void)MethodC:(selector) {
  //here i want to call MethodA of classA, and i will prefer if it is possible by sending the name of the method as selector in this method(methodC)

    }  
}

edit2::

Another example i want to do smthing like follwoing:

ClassB *b = [[ClassB alloc] nitWithTarget:self selector:@selector(methodfromClassA) object:nil];

Here i want to call a method of class A once some task in Class B is completed, and that too from class A.

I hope it is much clear now.

Edit3:

- (void)loadView {
    AsyncConnection *async =[[AsyncConnection alloc] init];
    [async getAsync:self callback:@selector(test1)];
}

above code is from first class

-(void)getAsync:(id)anObject callback:(SEL)selector {
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:anObject 
                                                                            selector:@selector(selector) 
                                                                              object:nil];
    [queue addOperation:operation];
    [operation release];

}

and above code is from second class. Here i want to call a method of first class which is passed as selector.

  • 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-17T00:36:22+00:00Added an answer on May 17, 2026 at 12:36 am
    - (void)loadView {
        AsyncConnection *async =[[AsyncConnection alloc] init];
        [async getAsync:self callback:@selector(test1)];
    }
    

    Other class:

    -(void)getAsync:(id)anObject callback:(SEL)selector {
        NSInvocationOperation *operation = [[NSInvocationOperation alloc] 
             initWithTarget:anObject 
                   selector:@selector(selector)
                     object:nil];
    
        [queue addOperation:operation];
        [operation release];
    
    }
    

    First, if you want to use the above pattern, remove the @selector() from @selector(selector). You already have the selector. Doing @selector(selector) will create the SEL named selector and not the selector passed in as the argument.

    Next, this seems like an odd pattern to start with; it’ll work, but any experienced Obj-C/iOS/Cocoa developer will get the willies looking at it. Since you wrote the AsyncConnection class, use the delegate pattern. I.e. in the class that implements loadView.

    That is, in AsyncConnection.h:

    @property(retain) ClassA *callbackHandler;
    

    And then:

    - (void)loadView {
        AsyncConnection *async =[[AsyncConnection alloc] init];
        [async setCallbackHandler: self];
    }
    

    Then, in AsyncConnection, you would refer to the callback handler directly as self.callbackHandler (or [self callbackHandler]).

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

Sidebar

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.