\n@interface NSApplication // system class\n{\n id _delegate;\n ...\n}\n-setDelegate: d;\n-(void)quit;\n\n@end\n\n\n@interface MyApplicationDelegate\n\n-(BOOL)applicationShouldQuit: sender;\n//-(void)applicationWillQuit: sender; // not implemented\n\n@end\n\n@implementation NSApplication\n\n-quit\n{\n // this isn't exactly how its done but you get the idea\n if([_delegate respondsToSelector: @selector(applicationShouldQuit:)] &&\n [_delegate applicationShouldQuit: self])\n {\n if([_delegate respondsToSelector: @selector(applicationWillQuit:)])\n {\n [_delegate applicationWillQuit: self];\n // proceed with quitting\n }\n }\n}\n\n@end\n
Its a way of adding additional behavior to an object by delegating key behavior to another object. Its used all through the Cocoa apis and its really useful since you just implement the methods to get the notifications you care about in your delegate - no subclassing required most of the time.
Somehow, I doubt this is what C# means by delegation.
Edit - inserted pre tags