• 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
Overriding -copyWithZone: the right way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Overriding -copyWithZone: the right way


  • Subject: Overriding -copyWithZone: the right way
  • From: Michael Becker <email@hidden>
  • Date: Fri, 5 Nov 2004 17:46:48 +0100

Hello all!

I have a subclass of NSCell (for a TableView) that is supposed to display an image and an NSPopUpButtonCell. Everything works fine so far, but I obviously need to override -copyWithZone:. Here's what I came up with:

- (id)copyWithZone:(NSZone *)zone {
PCShoppingCartCell *copy = [[ PCShoppingCartCell alloc] initImageCell:nil];
return copy;
}


This does not crash, but it looks so suspiciously memory-leaking... (the alloc/init is not paired with a release on my side). When trying to follow the (few) suggestions the docs give me, I tried this (but it did not work, the app crashed as soon as the TableView wanted to redraw):

- (id)copyWithZone:(NSZone *)zone
{
	PCShoppingCartCell *copy = [super copyWithZone:zone];
	[ copy _initSubCells]; // This inits and sets up the NSPopUpButtonCell
	return copy;
}

Can anybody give me advice on how I do this the right way?

Kind regards,
Michael

_______________________________________________
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: Overriding -copyWithZone: the right way
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: Overriding -copyWithZone: the right way
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: Getting a carbon's info string
  • Next by Date: Re: Getting a carbon's info string
  • Previous by thread: [SOLVED] Re: Missing created files
  • Next by thread: Re: Overriding -copyWithZone: the right way
  • Index(es):
    • Date
    • Thread