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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:19:42+00:00 2026-05-15T01:19:42+00:00

here is a quick question, i have my couple view controllers classes, and have

  • 0

here is a quick question,
i have my couple view controllers classes, and have some other classes.
i’ve found my self creating some methods in all of their implementation files, which are doing the same.

i would like to write some of my methods in a seperate file,
and import this file into my view controllers.
therefore, i will be able to run those methods from my current view controller,

In case this method will require a change, i will not need to re-write it in all my implementaion files.

Let me Sharp just one thing. I do not want to create a new object! and instantiate it.
i do want to be able to run this method just like i was doing: [self doSomething];

Please help to understand how this should be done.

i.e.
i have 3 view controllers, each has the bellow method:

-(void)doSomething:(id)sender{
//doing something
}

just want to have this doSomething method defined in one place,
and i could access it from my view controllers by running:
[self doSomething];

is it possible?

Thanks in advance.

  • 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-15T01:19:43+00:00Added an answer on May 15, 2026 at 1:19 am

    You want to do this by subclassing. First create a class where you want all your shared methods, as a subclass of UIViewController, let’s call it BaseViewController. For example you’d have this in your header file:

    @interface BaseViewController: UIViewController 
    {
    }
    -(void)doSomething:(id)sender;
    @end
    

    And then the corresponding definition in your .m file.

    Now when you want to create a new UIViewController subclass which has the shared methods make the new class a subclass of BaseViewController not UIViewController, like so:

    @interface MyViewController: BaseViewController
    {
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Really quick question here, some other people helped me on another problem but I
Just a quick question here. I have a program in which I need to
I have a quick question here. I know that the cakePHP find('first') function returns
Quick question, What have I done wrong here. The purpose of this code is
Just a quick newbie question here. I have a method that calculates a value
Another quick question here, I have this code: string sa[6] = { Fort Sumter,
Quick question/clarification required here. I have a DB table that will quite possibly have
Quick question, looking for some recommendations. I have a site that will be requesting
Here is a quick question, I have the following method within an object, why
Hi guys i have quick question, So i have uset UIViewController to push some

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.