Here is a quick question, I have my own pair of view controller classes, and there are some other classes I have implemented all of my own The files have created some methods, which are the same.
I would like to write some of my own methods in a different file, and import this file into my view. Therefore, I may be able to run those methods with my current view controller,
If this method requires a change, I will not need to re-write it in all its implementation files.
Sharpen me aside I do not want to create a new object! And get it immediately. I want to be able to run this method as I was doing: [doing something];
Please help understand how this should be done.
i.e. I have 3 view controllers, each one has a Bile method:
- (zero) doSomething: (ID) sender {// do something}
Just want to do this. Some method is defined in one place, and I can run it from my view controllers: [self doSomething];
Is this possible?
In advance thank you
You want to do it by subclassing it. First create a class where you want all your shared ways, such as the subclass of the UIViewController, it is called the basic visual controller. For example, this will be in your header file:
@interface BaseViewController: UIViewController {} - (zero) doSomething: (ID) sender; @end
and then related definitions in your .m file.
Now that you want to create a new UIViewController subclass whose shared methods are creating new cells, there is no sub-class UIViewController of the BaseViewController, such as:
@interface MyViewController : BaseViewController {} @end
Comments
Post a Comment