KVO vs NSNotification vs protocol/delegates?

前端 未结 5 912
暖寄归人
暖寄归人 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:16

    In my opinion KVO is better because of it's zero-overhead advantages. Notifications has overhead even if you aren't using/observing them. To improve that you can use different NotificationCenters but even with that some overhead will be there (correct me if I'm wrong). KVO is little complex but its worth when you have to observe lots of stuff.

提交回复
热议问题