Created
May 23, 2013 12:10
-
-
Save xandrucea/5635627 to your computer and use it in GitHub Desktop.
Creating delegates
This file contains hidden or 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
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