iPhone: Sharing protocol/delegate code

Posted by pion on Stack Overflow See other posts from Stack Overflow or by pion
Published on 2010-03-27T18:52:58Z Indexed on 2010/03/27 19:13 UTC
Read the original article Hit count: 377

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about protocol