• 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: Forcing allocation of a subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing allocation of a subclass


  • Subject: Re: Forcing allocation of a subclass
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 25 Jan 2009 15:07:25 +0100


Le 25 janv. 09 à 14:50, João Varela a écrit :

Olá António

I think your method must be corrected like this:


On 2009/01/25, at 07:28, email@hidden wrote:

@implementation PDFDocument (PDFDocument_Alloc)

+ (id)replacementAllocWithZone:(NSZone *)zone
{
	if ([self class] == [PDFDocument class]) {
		return [ANPDFDocument replacementAllocWithZone:zone];
	} else {
		return [super allocWithZone:zone];
	}
}


Note that you have to invoke the class method of self in order to compare it properly. Otherwise you are comparing a pointer to a class and the class name, which is the same as comparing apples with oranges. For further information read the introspection chapter in the Cocoa Fundamentals Guide:


'self' is a Class object as it's a class method, and +[NSObject Class] also return a Class (and not a class name).


I don't understand the issues and saw nothing about it in the link you provide.

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_7.html

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: Forcing allocation of a subclass
      • From: João Varela <email@hidden>
References: 
 >Re: Forcing allocation of a subclass (From: João Varela <email@hidden>)

  • Prev by Date: Re: Forcing allocation of a subclass
  • Next by Date: Re: Forcing allocation of a subclass
  • Previous by thread: Re: Forcing allocation of a subclass
  • Next by thread: Re: Forcing allocation of a subclass
  • Index(es):
    • Date
    • Thread