• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Abstract base classes in Objective C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Abstract base classes in Objective C


  • Subject: Re: Abstract base classes in Objective C
  • From: Kevin Viggers <email@hidden>
  • Date: Thu, 14 Apr 2005 03:00:54 -0600

Hi Andrew,

You may find it interesting to know that the Java 'interface' was (or at least claimed to be by those close to the project) inspired by Objective-C protocols.

"They all joined us in late '92 - early '93 after we had written the first version of Oak. I'm pretty sure that Java's 'interface' is a direct rip-off of Obj-C's 'protocol' which was largely designed by these ex-NeXT'ers..."

http://groups-beta.google.com/group/comp.sys.next.advocacy/browse_frm/ thread/4be2018ec29e57d7/9da24fa747f7bbe8?q=is+a+direct+rip-off+of+Obj- C's&rnum=1#9da24fa747f7bbe8

My guess would be that the distinct typing syntax stems from the fact that, in objC, the space of names for protocols does not clash with that of classes. This cannot be said for interface types in Java. To use the most prevalent example, it is completely valid to have a class named NSObject, and have protocol named NSObject. See the following for more details:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Protocols/NSObject.html
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSObject.html#//apple_ref/occ/cl/NSObject


It may not be clear, but this syntax also provides some flexibility; for example, you can specify that an object conform to multiple protocols like so:
id <MyProtocol, YourProtocol, SomeOtherProtocol> obj = [foo getAnObject];




On 14-Apr-05, at 1:24 AM, Andrew White wrote:


Kevin Ballard wrote:

Any suggestions? Are protocols what I'm looking for?
I believe protocols are what you want. What's the problem you're having with them?
Just to clarify, this is how you use an object that conforms to a protocol:
id <MyProtocol> obj = [foo getAnObject];
[obj method1];

I was hoping it would be transparent whether I was using an "abstract base class" or a concrete class, while the above code requires different syntax for a class than a protocol.



Thanks for the help, though.

--
Andrew White

----------------------------------------------------------------------- ---
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Abstract base classes in Objective C (From: Andrew White <email@hidden>)
 >Re: Abstract base classes in Objective C (From: Kevin Ballard <email@hidden>)
 >Re: Abstract base classes in Objective C (From: Andrew White <email@hidden>)

  • Prev by Date: Re: Cocoa from C++ (dont want to mix it)
  • Next by Date: Re: Cocoa from C++ (dont want to mix it)
  • Previous by thread: Re: Abstract base classes in Objective C
  • Next by thread: Re: Abstract base classes in Objective C
  • Index(es):
    • Date
    • Thread