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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:48:18+00:00 2026-06-13T05:48:18+00:00

I have for example this method: -(void)customSum { NSLog(@show something); } in HomeView.m and

  • 0

I have for example this method:

-(void)customSum {
NSLog(@"show something");
}

in HomeView.m and I want to call that method in all other files, for example in ArticleView.m. Can I do something like:

[HomeView customSum];

or something similar? How can I do that?

  • 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-06-13T05:48:19+00:00Added an answer on June 13, 2026 at 5:48 am

    It doesn’t sound like are trying to subclass anything (which would be why people are mentioning inheritance). If you are, than see the other answers.

    The obj-c way to do this would be the following: you want to have HomeView.h declare an interface for a class HomeView, and have the method be either a class method or an instance method. Like so:

        @interface HomeView : UIView
        - (void)anInstanceMethod;
        + (void)aClassMethod;
        @end
    

    I’m assuming since these are”views” you are deriving from UIView.
    Then you would have HomeView.m implementing the method:

        @implementation HomeView
        - (void)anInstanceMethod
        {
            // Do Something
        }
        + (void)aClassMethod
        {
            // Do Something else
        }
        @end
    

    Then, in ArticlViewe.m (Where you have an implementation of a class ArticleView declared in ArticleView.h (This is the standard way to do it, though you can put in an interface in a .m file, but you don’t wan’t to include a .m file, so the class wouldn’t be visible outside the file).

        #include "HomeView.h"
    
        ...
            [HomeView aClassMethod]; // Call the class method on the class
            HomeView *homeView = [HomeView new];
            [homeView anInstanceMethod]; // Call the instance method on an instance
        ...
    

    If this is all new to you, you should probably get a book on Objective-C and iOS development.

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

Sidebar

Related Questions

For example I have a method that looks like this [self performSelectorOnMainThread:@selector(someMethod) withObject:data waitUntilDone:YES];
Example: I have a selector like this, which I give to another method as
Assume I have method void SomeMethod(Action callback) This method does some work in background
I have this method (simplified): void DoSomething(IEnumerable<int> numbers); And I invoke it like this:
If we have a method: public void doSomething(){ synchronized(this){ //some code processing here }
i have this example: class One { public void testOne(){System.out.println(One!!!);} public void testTwo(){System.out.println(One!!!);} }
I have this method: private delegate void watcherReader(StreamReader sr); private void watchProc(StreamReader sr) {
Let's say I for example have this class that generates Fibonacci numbers: public class
For example, I have a method: - (void)customizeAppearance { [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
How can I select the good method (I have in the example below show

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.