I know that in Objective-C you should never retain your delegates because it may cause a retain-cycle, however, how do you know the difference between a delegate and a non-delegate object ? Can't it be said that just sending a message to any object is delegating work to that object ?
+2
A:
A delegate in Objective-C has a fairly well established definition. They're typically used in classes that are already implemented, but have some options for customization.
For example, the UIApplicationDelegate
is used to implement application specific behavior so that you don't have to subclass UIApplication
. This helps to minimize boilerplate code.
Also, delegate objects are usually kept around using the delegate property. I would argue that any object that isn't the delegate property, isn't a delegate object. The delegate objects are usually used to act on behalf of the regular object.
I hope this helps, your question was quite open-ended.
Ben S
2010-03-14 21:23:57
There are other delegate-like things, which you likewise shouldn't be retaining, like data sources.
Jonathan Sterling
2010-03-15 06:15:08