• 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: Application failing on copyWithZone:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application failing on copyWithZone:


  • Subject: Re: Application failing on copyWithZone:
  • From: Andrew Merenbach <email@hidden>
  • Date: Sun, 18 Jun 2006 16:50:41 -0700

Hi again, Kevin.  Here's how -copyWithZone: should look:

- (id)copyWithZone:(NSZone *)zone {
	id copy = [[[self class] allocWithZone:zone] init];
	[copy setThisAttribute:[self getThisAttribute]];
	[copy setThatAttribute:[self getThatAttribute]];

	return copy;
}

Accessors and mutators prove very handy here.

Another question: is AccountDocument an NSDocument subclass, or is it just a custom class of yours? (If it's actually an NSDocument subclass, you wouldn't want to be serializing that, but instead would want to encode a custom class with your data in it.)

What warning did you receive?

Best wishes,
	Andrew


On Jun 18, 2006, at 3:33 PM, Kevin Hoctor wrote:


On Jun 18, 2006, at 5:22 PM, Andrew Merenbach wrote:

Hi, Kevin. Sorry if this is a stupid question (and it probably is), but have you implemented -copyWithZone: in your AccountDocument class? You'll need it for NSCoding to work properly with it, since it's not a class that's serializable by default. Once again, I'm probably preaching to the choir, so forgive me if I am, but basically just create a copy of your object and set its attributes to be the same as the original's, then return the copy (NOT autoreleased).

Again, sorry if I'm speaking to someone who has tried this, but you did not mention it anywhere so I thought that I would.

Best wishes,
	Andrew

Hi Andrew. I've tried to do that, but it caused a warning. I tried to do some research on the right way to do it but I didn't find enough information to help. What am I actually supposed to put in this routine?


Peace,
Kevin

_______________________________________________ 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: Application failing on copyWithZone:
      • From: Kevin Hoctor <email@hidden>
References: 
 >Application failing on copyWithZone: (From: Kevin Hoctor <email@hidden>)

  • Prev by Date: [ANN] Cocoa Mentoring and Tutoring
  • Next by Date: Stopping an NSRunLoop OR getting NSDistributedNotificationCenter notifications
  • Previous by thread: Re: Application failing on copyWithZone:
  • Next by thread: Re: Application failing on copyWithZone:
  • Index(es):
    • Date
    • Thread