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?
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:
I’m assuming since these are”views” you are deriving from UIView.
Then you would have HomeView.m implementing the method:
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).
If this is all new to you, you should probably get a book on Objective-C and iOS development.