help with NSCopying
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.