Revision: 34508
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 23, 2010 08:44 by gerhardsletten
Initial Code
// Delegatior.h #import <Foundation/Foundation.h> @protocol SaveActionDelegate; @interface Delegatior : NSObject { id <SaveActionDelegate> delegate; } @property (nonatomic, assign) id <SaveActionDelegate> delegate; - (IBAction)cancel:(id)sender; - (IBAction)save:(id)sender; @end @protocol SaveActionDelegate - (void)delegationObject:(Delegatior *)obj didSave:(BOOL)save; @end // Delegatior.m #import "Delegatior.h" @implementation Delegatior @synthesize delegate; - (IBAction)cancel:(id)sender { [delegate delegationObject:self didFinishWithSave:NO]; } - (IBAction)save:(id)sender { [delegate delegationObject:self didFinishWithSave:YES]; } - (void)dealloc { [delegate release]; [super dealloc]; } @end // Delegate.h #import <Foundation/Foundation.h> #import "Delegatior.h" @interface Delegate : NSObject <SaveActionDelegate> { } - (void)delegationObject:(Delegatior *)obj didSave:(BOOL)save; @end // Delegate.m #import "Delegate.h" @implementation Delegate - (void)viewDidLoad { [super viewDidLoad]; Delegatior *delegatior = [[Delegatior alloc] init]; delegatior.delegate = self; } - (void)delegationObject:(Delegatior *)obj didSave:(BOOL)save { [self doStuff]; } @end
Initial URL
Initial Description
Delegate is the object that are listning to Delegatior.
Initial Title
Generic Objective-C Delegation template
Initial Tags
iphone
Initial Language
Objective C