- Make an
id instance variable in your class, and make methods to set and get it:
id delegate;
...
-(void) setDelegate: (id) del
{
delegate = del; // you don't need to retain it
} // setDelegate
- (id) delegate
{
return (delegate);
} // delegate
- Make a category on
NSObject so the compiler won't generate warnings, and also to document the delegate methods you support:
@interface NSObject(BWStitchViewDelegate)
- (BOOL) shouldHandleStuff: (NSData *) data;
@end
- Check to make sure your delegate understands the message before sending it.
...
if ([delegate respondsToSelector: @selector(shouldHandleStuff:)]) {
BOOL blah;
blah = [delegate shouldHandleStuff: somedata];
if (blah) ...
}