Example:
The MacOS API known as Cocoa uses Delegation to specify various behaviors within the app. A Delegate is a separate object that implements a set of methods that are called by an original object. For example an NSApplication calls the applicationWillTerminate method in the NSApplicationDelegate (which is overridden by the programmer to add custom cleanup code) when the application is about to terminate.
The primary benefit to Delegation is the minimization of duplicate method tables if multiple objects would otherwise have the same methods/behavior. Having them all reference the same delegate is better than each having their own copy of the methods.
However as far as I can tell NSApplication is a singleton and only one instance is ever created thus negating the aforementioned benefit.
Is there any benefit to using a delegate to specify behavior of a singleton rather than having the user override the singleton class and providing their own methods all in one place?
NSApplicationDelegateexists to provide limited overridability in terms of how theNSApplicationworks. That would be unrelated to whetherNSApplicationhappens to be a singleton or not. In short, I don't think you can assume that individually applied patterns explicitly account for one another, these might simply be two separate design decisions where the tiny bit of overlap that they do have was simply ignored because it was not considered important (maybe not even considered).NSApplicationand override methods directly though.