Skip to content

Instantly share code, notes, and snippets.

@jonbalbarin
Created September 17, 2011 02:50
Show Gist options
  • Save jonbalbarin/1223571 to your computer and use it in GitHub Desktop.
Save jonbalbarin/1223571 to your computer and use it in GitHub Desktop.
making a category on a class to contain its protocol methods
////////////////////////////////////////////////////////////////////////////////
// MyProtocol.h
////////////////////////////////////////////////////////////////////////////////
@protocol MyProtocol <NSObject>
-(void) thisThingDidDoSomething:(OriginalThing*)sender;
-(void) thisThing:(OriginalThing*)sender didDoSomethingWithThing:(Thing*)thing;
@end
////////////////////////////////////////////////////////////////////////////////
// MyViewController.h
////////////////////////////////////////////////////////////////////////////////
@interface MyViewController : UIViewController
@end
@interface MyViewController(MyProtocolCategory) <MyProtocol>
@end
////////////////////////////////////////////////////////////////////////////////
// MyViewController.m will contain all the standard VC methods
// MyViewController+MyProtocolCategory contains all the MyProtocol stuff
////////////////////////////////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment