Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclass



Sorry, that doesn't do what I need.

I have an object (call it F) of class foo and an object of class foo-bar (call it FB).

class foo-bar is a sub-class of foo.
class foo does implement some methods but would like to leave others to the sub-classes.

Another object (call it test) would like to call methods on objects of super-class type foo. However, foo is never instantiated, only subclasses are. Also, I'd like to have foo declare some methods that it doesn't implement but I would like to guarantee sub-classes implement. Protocols aren't that strict.

Please correct me if I'm wrong here.`

Is there another way to do this in Obj-C.

______________________________________________________________________
Previous message from Wade Tregaskis on 6/14/03 at 11:06 AM +1000
**********************************************************************
I would like to create a super class with some abstract/virtual methods. In Java I know they are called abstract methods.

I'd like to declare some methods that the subclasses have to implement but that the super class provides no implementation for. How do I do this in Obj-C?

The mechanism in ObjC is to use protocols. A class can inherit any number of these, and they specify what methods the class must offer to implement the protocol. Check out <http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/ 3objc_language_overview/chapter_3_section_9.html> for an introduction.

Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.