什么是C#接口和一个Objective-C协议之间的区别?

什么是C#接口和一个Objective-C协议之间的区别?

问题描述:

有什么一个C#接口和一个Objective-C协议之间的区别?我问,因为我是在深入ASP.NET MVC和我试图抓住一些新的概念,它会帮助,如果我可以将它们与我的Objective-C编程的iOS背景。

What's the difference between a C# Interface and an Objective-C Protocol? I ask because I'm diving into ASP.NET MVC and I'm trying to grasp some of the new concepts and it will help if I can relate them to my Objective-C iOS programming background.

感谢您的帮助!

,他们基本上是相同的。在Objective-C 2.0,不过,你可以标记在协议的一些方法,可选(使用 @optional 预选赛),这意味着,实施该协议的类AREN 'T需要实现这些方法。

They're basically the same. In Objective-C 2.0, though, you can mark some methods in a protocol as "optional" (using the @optional qualifier), which means that classes that implement the protocol aren't required to implement those methods.