On Tue, Mar 18, 2014 at 8:11 PM, Kyle Sluder <k...@ksluder.com> wrote:
> On Tue, Mar 18, 2014, at 05:30 PM, William Squires wrote: > > Hi all! > > Obviously (IIRC) a pure abstract class would map to a formal protocol > > in ObjC (or a class interface in languages such as REALbasic/Xojo, or > > VB 6). My best guess is to: > > No, that's not what protocols are for. Any class can conform to any > protocol. > > Mmmm ... well, generally speaking, any class can "conform" to any abstract class as well. I believe that one distinction is that an Objective-C @class can conform to an endless number of @protocols while a Java class can only directly *subclass* ONE abstract class, pure or not. But similarly, in Objective-C, a @class can subclass only one @class at a time. A _better_ analogy to an Objective-C @protocol would be a formal Java interface. So, Kyle may have good reasons for his answer - but if I understand the essence of your question, I would say yes, a pure "abstract class" (where no methods are implemented) or a formal "interface" (where method signatures have no implementation) in a language like Java ... would both indeed be _similar_ to a formal @protocol in Objective-C. And as I think I hear in your voice, the essence is that the interface, pure abstract class or protocol ALL declare a formal contract or API that some other concrete class implements, adopts or conforms to. Pick your terms but indeed the language constructs you've listed here are, at some level, analogous. And yes, I think your Objective-C attempt to replicate the notion of an abstract class in Java demonstrates an understanding of protocols and classes in Objective-C. It is clearly a sort of "blend" of the two. Hope that helps. -Luther _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com