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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:52:48+00:00 2026-05-23T07:52:48+00:00

Basically, I want to call a function of a main class within a subclass

  • 0

Basically, I want to call a function of a main class within a subclass that the main class holds a pointer to.
I know I can just get the main class to initiate the subclass and attach the function to it. But I do not want that, I want the subclass to initiate itself with its init function.
Is there any way I can call doSomething from someClass?
Some basic code to show what I want:
In MainViewController.h:

@class SomeClass;

@interface MainViewController : UIViewController {
        SomeObject *someInformation;
        SomeClass *someInstance;
}
@property (nonatomic, strong) SomeClass *someInstance;

-(void)doSomething:(id)sender;
@end

In MainViewController.m:

@implementation MainViewController
@synthesize someInstance;
-(void)doSomething:(id)sender {
    //do something to someInformation
}
@end

In SomeClass.h:

@interface SomeClass : NSObject {
    UIStuff *outstuff;
}
@property (strong, nonatomic) UIStuff *outstuff;
-(void)somethingHappened:(id)sender;
@end

In SomeClass.m

@implementation SomeClass
@synthesize outStuff;
-(IBAction)somethingHappened:(id)sender {
    //call doSomething to the main class that points to this class
}
@end
  • 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-23T07:52:48+00:00Added an answer on May 23, 2026 at 7:52 am

    Your terminology is shaky. Classes do not “hold” other classes. In your case, instances of class MainViewController have pointers to objects of class SomeClass. I am not being pedantic; poor terminology such as this casts doubt on one’s understanding of underlying and important concepts.

    That said, SomeClass objects need a reference to a MainViewController object if you want a SomeClass object to be able to send a message to a MainViewController instance. From the code you have posted, no such reference exists. You either need to expand the SomeClass interface to store an explicit reference to a MainViewController object, or you can employ something slightly more indirect (at least conceptually) via delegation. However, because you have not provided case-specific information, our solutions will be formed lacking detail-derived insight.

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

Sidebar

Related Questions

I want to do what setTimout does, manually, with no timeout. setTimeout(function,0,args); Just call
Basically when I click a button I want to call a function and run
I basically want to make things easier by just looping LinkButtons instead of making
So I basically want to have a static method in my AR class to
I just basically want to add about 20 and sometimes 80 Proximity Alerts with
What i basically want to do is to get content from a website and
I have an SPListItemCollection. I basically want to get one of the items (randomly)
Basically, I have a Linked List which implements a display() function that simply loops
I'm tying to create a class that holds a reference to another classes method.
I know it's possible to call the calling function, but is it possible to

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.