what is Delegate in iPhone?

前端 未结 5 836
日久生厌
日久生厌 2020-12-09 05:18

what is the exact meaning of delegate in iphone?how it is implemented in UIViewController?

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 05:46

    A delegate is an object that usually reacts to some event in another object and/or can affect how another object behaves. The objects work together for the greater good of completing a task. Typically a delegate object will be shared by many other objects that have a more specific task to carry out. The delegate itself will be more abstract and should be very reusable for different tasks. The object which contains the delegate typically sends the delegate a message when a triggered event occurs, giving the delegate an opportunity to carry out its specified task.

    There's more documentation here that you should read to understand the delegate pattern in Cocoa and Cocoa touch, particularly with how delegation is used between UIWindow and UIView. It is an integral design pattern in iPhone architecture and one that should be mastered if you wish to design a clean application.

提交回复
热议问题