Wenfengcheng / xamarin-notes

xamarin journal
MIT License
3 stars 0 forks source link

Xamarin.iOS protocols and delegates #17

Open Wenfengcheng opened 6 years ago

Wenfengcheng commented 6 years ago

Protocols

Protocols are a loose contract Interfaces, where methods are declared as required or optional. A class that implement a protocol must implement only required methods.

Delegates

From the Xamarin documentation: iOS uses Objective-C delegates to implement the delegation pattern, in which one object passes work off to another. The object doing the work is the delegate of the first object. An object tells its delegate to do work by sending it messages after certain things happen. Sending a message like this in Objective-C is functionally equivalent to calling a method in C#. A delegate implements methods in response to these calls, and so provides functionality to the application. Applications in iOS often use delegates when one class calls back to another after an important action occurs.

http://blog.tpcware.com/2016/08/the-xamarin-implementation-of-ios-protocols-and-delegates/