Hi, I understand using delegates in associated with other objects (i.e. UITextField etc.) But I am trying to find a simple example of setting up / using a custom delegate independently. Any help / pointers would be much appreciated.
My understanding so far is:
#import <Foundation/Foundation.h>
@class TheBox;
@protocol TheBoxDelegate <NSObject>
-(void)theBoxDelegateWillDoSomething:(TheBox *)theBox;
@end
@interface TheBox : NSObject {
id <TheBoxDelegate> delegate;
}
@property(assign) id <TheBoxDelegate> delegate;
@end
.
#import "TheBox.h"
@implementation TheBox
@synthesize delegate;
@end
// Some other class will conform to <TheBoxDelegate> and
// implement the method -(void)theBoxDelegateWillDoSomething:
The problem I am having within a simple basic app is where to instantiate this, how to manage it memory wise and how to call it / get the delegate to give some simple feedback. One of the initial concepts that was tripping me up was that the method header defined in the protocol is implemented on the object conforming to the protocol.
Gary.