KVO vs NSNotification vs protocol/delegates?

前端 未结 5 916
暖寄归人
暖寄归人 2020-12-12 14:24

I have some idea of which to use when but the exact usage is still not clear to me. Can someone explain with example?

5条回答
  •  半阙折子戏
    2020-12-12 15:20

    Even when all three would serve your need in a situation, delegate would still be a prefer option:

    1. Reuseability.
    2. Self documented. By examining the class's header file, one would immediately recognize what / how the data exchanged taking places.

提交回复
热议问题