Last active
May 3, 2017 07:16
-
-
Save dniswhite/badf50cde5af2dc7faf9 to your computer and use it in GitHub Desktop.
simple implementation for a delegate on a view controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@class SomeViewController; | |
@protocol SomeViewControllerDelegate <NSObject> | |
-(void)delegateMethodName: (SomeViewController *) controller; | |
@end | |
@interface SomeViewController : UIViewController | |
@property (nonatomic, weak) id<GFNewUserDelegate> delegate; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "delegate.h" | |
@interface SomeViewController () | |
@end | |
@implementation SomeViewController | |
- (void) someMethodToCallDelegate { | |
[self.delegate delegateMethodName:self]; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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