• 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: Memory management and Objects.(Newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management and Objects.(Newbie)


  • Subject: Re: Memory management and Objects.(Newbie)
  • From: Aaron Boothello <email@hidden>
  • Date: Sun, 10 Oct 2004 01:30:17 +0800

Thanks for the link. I read up on it as well as some o'reilly articles on memory management. But im still unclear as to the implementation of making 'deep' copies of instance variables in my subclasses.
i override copyWithZone like this:

- (id)copyWithZone:(NSZone *)zone
{
myTextureClass *copy = [super copyWithZone:zone];
[copy setImage:[self getImage]];
[copy setName:[self getName]];
return copy;
}

for an example the setImage method looks like this:

-(void)setImage:(NSImage *)img
{
image = [img copy];
}

and when i want to make a copy of a particular myTextureClass instance i just call:

myTextureClass *newTextureClass;
newTextureClass = [oldTextureClass copy];

I dosent seem to work. And i cant seem to figure out what im doing wrong. Any assistance would be greatly appreciated.

Cheers,
Aaron.

On 08/10/2004, at 2:30 AM, Nick Zitzmann wrote:

On Oct 7, 2004, at 11:39 AM, Aaron Boothello wrote:

i want a second object that is an identical copy of mySuperObject. ( i dont want two rferences to the same object by just using 'retain').
i can create it by:
mySuperObject2 = [[superObject alloc] init];

If i edit the superObject2, the changes should not appear in superObject.

How do i do this ?

<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Protocols/NSCopying.html#//apple_ref/occ/intf/NSCopying>

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________
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: Memory management and Objects.(Newbie)
      • From: Nick Zitzmann <email@hidden>
References: 
 >Memory management and Objects.(Newbie) (From: Aaron Boothello <email@hidden>)
 >Re: Memory management and Objects.(Newbie) (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Getting Data out of NSImages
  • Next by Date: Re: Getting Data out of NSImages
  • Previous by thread: Re: Memory management and Objects.(Newbie)
  • Next by thread: Re: Memory management and Objects.(Newbie)
  • Index(es):
    • Date
    • Thread