• 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
help with NSCopying
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help with NSCopying


  • Subject: help with NSCopying
  • From: Ted Lowery <email@hidden>
  • Date: Fri, 10 Jan 2003 23:44:34 -0500

How do I implement -copy for an object?

I have an object:

@interface ObjColorScheme : NSObject <NSCopying> {
NSColor* lineColor;
NSColor* fillColor;
BOOL showLine;
BOOL showFill;
}

then I provide a method in ObjColorScheme:

- (id)copyWithZone:(NSZone*)zone {
// what goes here?
}

Somewhere in my code, I'd like to do something like...

ObjColorScheme* a = [[ObjColorScheme alloc] init];
[a lineColor:[NSColor redColor]];
...
ObjColorScheme* b = // copy of a, how? [a copy] ?
[b lineColor:[NSColor blueColor]];

I want b to be a duplicate of a, but both to be separate objects that can be changed independently. at this point a's lineColor is red and b's lineColor is blue.

I'm not sure from the docs how to set this all up to work right.

Thanks for any help.

Cheers, Ted
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Aqua Human Interface and Safari
  • Next by Date: Finding the parent of an outline view item
  • Previous by thread: [ANN]: Updated AppKit release notes now online
  • Next by thread: Re: help with NSCopying
  • Index(es):
    • Date
    • Thread