• 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: Cocoa-dev Digest, Vol 4, Issue 496
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa-dev Digest, Vol 4, Issue 496


  • Subject: Re: Cocoa-dev Digest, Vol 4, Issue 496
  • From: Daniel Child <email@hidden>
  • Date: Fri, 25 May 2007 01:24:38 -0400

Actually, I'm interested in how the corresponding "+" version would go as well. The more I think about this the more confusing it seems.

The user is going to call:

AbstractClass *o ;
[o initWithArg: @"A"]; // or @"B"

o should then be a pointer to an AbstractClass instance, but in the init method below (assuming - not +), o (which is the same as self) will be deallocated and now point to an object of type ConcreteA.

So THIS is how the equivalent of Java's typecasting is performed!!??

Thanks.

On May 25, 2007, at 12:15 AM, Jeff Laing wrote:

In Objective C, however, you can have your abstract class do
something like:

+ init {
	[self dealloc];
	self = [[concreteclass alloc] more SpecialisedInit];
	return self;
}

Oops, thats supposed to be -init, not +init because its an instance method.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa-dev Digest, Vol 4, Issue 496
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: adding an NSPDFImageRep to an NSImage scales (down) image
  • Next by Date: Re: abstract class
  • Previous by thread: Re: Cocoa-dev Digest, Vol 4, Issue 496
  • Next by thread: Re: Cocoa-dev Digest, Vol 4, Issue 496
  • Index(es):
    • Date
    • Thread