Are delegates and callbacks the same or similar?

后端 未结 5 787
孤街浪徒
孤街浪徒 2020-12-07 22:10

Are delegates the same thing as callbacks? Or are they related somehow?

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 22:44

    The service class has a variable function called a delegate. The calling class has a preferred function that it wants run called a callback.

    The calling class sets the delegate to it's callback.

    The difference between a delegate and a callback is the perspective: The service class calls the delegate that is set to the calling classes callback.

提交回复
热议问题