Skip to content

Instantly share code, notes, and snippets.

@xandrucea
Created May 23, 2013 12:10
Show Gist options
  • Save xandrucea/5635627 to your computer and use it in GitHub Desktop.
Save xandrucea/5635627 to your computer and use it in GitHub Desktop.
Creating delegates
In Klasse die das delegate erhalten soll:
@protocol CustomAlertDelegate <NSObject>
-(void)dismissMyViewController:(UIViewController *)aViewController;
@end
define the delegate property:
@property (strong, nonatomic) id<CustomAlertDelegate> myDelegate;
inside the implementation of this Class, to check if the button has been delegated:
- (IBAction)btBottom:(id)sender{
if([_myDelegate respondsToSelector:@selector(dismissMyViewController:)]){
[_myDelegate dismissMyViewController:self];
}
}
Add delegate Methods (from protocol) into the class you want to delegate from:
-(void)dismissMyViewController:(UIViewController *)aViewController{
// what should happen after delegation
}
and set the delegate to the class you want to delegate from:
init class
initClass.myDelegate = self;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment