• 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: Ondra Cada <email@hidden>
  • Date: Thu, 14 Apr 2005 14:18:48 +0200

Will,

first thing, there is nothing as "abstract clase" in a dynamic object system: first, it is impossible to ensure its abstracness; second, it is not sensible to do that for there are better ways to implement the funtionality. Read on "class clusters": a class cluster is, in fact, an abstract class -- and more.

Also:

On 14.4.2005, at 10:47, Will Mason wrote:

// Exist only to provide a consistent interface
@interface AbstractBaseClass : NSObject
{
}

- (int) publicMethodOne;
- (void) publicMethodTwo: (int) x;
- (void) publicMethodThree: (int) x withModifier: (int) Y;

@end

What I do, and I can't say that this is the norm, is to raise an exception when I define what I would want to be a purely abstract method that subclasses must override. Since Objective-C has no such thing as pure virtual (using C++ lingo) methods, then this, as far as I can tell, is a good solution.

Quite.

And in a sense, it *is* a perfect norm and *the* way of doing that, only instead the exception use the message which is standard exactly for this:

-(void)publicMethod { // "abstract" method
  [self doesNotRecognizeSelector:_cmd];
}

As for the original question

On Apr 14, 2005, at 12:39 AM, Andrew White wrote:

Any suggestions? Are protocols what I'm looking for?

Perhaps, but IMHO informal protocols (i.e., categories without an implementation) may be closer to what you want. Depends. Read on both, and select which suits you best.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


_______________________________________________
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


  • Follow-Ups:
    • Re: Abstract base classes in Objective C
      • From: Chaz McGarvey <email@hidden>
References: 
 >Re: Abstract base classes in Objective C (From: Will Mason <email@hidden>)

  • Prev by Date: NSMenuItem - setting font size?
  • Next by Date: Re: Null entries in property lists
  • Previous by thread: Re: Abstract base classes in Objective C
  • Next by thread: Re: Abstract base classes in Objective C
  • Index(es):
    • Date
    • Thread