Skip to content

Instantly share code, notes, and snippets.

@dniswhite
Last active May 3, 2017 07:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dniswhite/badf50cde5af2dc7faf9 to your computer and use it in GitHub Desktop.
Save dniswhite/badf50cde5af2dc7faf9 to your computer and use it in GitHub Desktop.
simple implementation for a delegate on a view controller
#import <UIKit/UIKit.h>
@class SomeViewController;
@protocol SomeViewControllerDelegate <NSObject>
-(void)delegateMethodName: (SomeViewController *) controller;
@end
@interface SomeViewController : UIViewController
@property (nonatomic, weak) id<GFNewUserDelegate> delegate;
@end
#import "delegate.h"
@interface SomeViewController ()
@end
@implementation SomeViewController
- (void) someMethodToCallDelegate {
[self.delegate delegateMethodName:self];
}
@end
#import "delegate.h"
@interface SomeDelegateUser ()
<SomeViewControllerDelegate>
@end
@implementation SomeDelegateUser
- (void) variousFoo {
SomeViewController *controler = [[SomeViewController alloc] init];
controller.delegate = self;
}
-(void)delegateMethodName: (SomeViewController *) controller {
// handle the delegate being called here
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment