What is the difference between Delegate and Notification?

后端 未结 5 535
臣服心动
臣服心动 2020-12-04 10:15

What is the difference between Delegate and Notification?

I understood like delegate and protocol,

@protocol classADelegate

-(void)DelegateMethod;

         


        
5条回答
  •  臣服心动
    2020-12-04 10:56

    Delegate is passing message from one object to other object. It is like one to one communication while nsnotification is like passing message to multiple objects at the same time. All other objects that have subscribed to that notification or acting observers to that notification can or can’t respond to that event. Notifications are easier but you can get into trouble by using those like bad architecture. Delegates are more frequently used and are used with help of protocols.

提交回复
热议问题