Re: Understanding the docs. UIApplication for iOS
Re: Understanding the docs. UIApplication for iOS
- Subject: Re: Understanding the docs. UIApplication for iOS
- From: Jens Alfke <email@hidden>
- Date: Tue, 04 Jun 2013 11:16:31 -0700
On Jun 4, 2013, at 10:44 AM, Fritz Anderson < email@hidden> wrote: What makes a protocol different is that a class can make a promise to implement a certain API; and a parameter (or whatever) can demand that API without having to specify a particular class. The compiler enforces the promise and the compatibility as best it can.
It’s exactly like an ‘interface’ in Java (and a lot of other languages have identical concepts.) It lets a class inherit an API but not implementation. It’s a less complex alternative to multiple inheritance — you can inherit from multiple things, but only one of them can have an implementation, so you don’t get the awful problems you find in C++ when multiple base classes implement the same method.
If you aren’t familiar with Java interfaces, then think of a protocol as a special kind of class that doesn’t implement any of its methods, so you have to implement/override them all. But in exchange a class gets to inherit from multiple protocols in addition to a base class.
—Jens |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden