iPhone: Sharing protocol/delegate code
- by pion
I have the following code protocol snippets:
@protocol FooDelegate;
@interface Foo : UIViewController {
id delegate;
}
...
@protocol FooDelegate
... // method 1
... // method 2
...
@end
Also, the following code which implements FooDelegate:
@interface Bar1 : UIViewController { ... }
@interface Bar2 : UITableViewController { ... }
It turns out the implementation of FooDelegate is the same on both Bar1 and Bar2 classes. I currently just copy FooDelegate implementation code from Bar1 to Bar2.
How do I structure/implement in such a way that Bar1 and Bar2 share the same code in a single code base (not as currently with 2 copies) since they are the same?
Thanks in advance for your help.