even after the longish diatribes on copying....
even after the longish diatribes on copying....
- Subject: even after the longish diatribes on copying....
- From: Theodore Petrosky <email@hidden>
- Date: Mon, 14 Jun 2004 06:50:44 -0700 (PDT)
I apologize.. even after reading eveything I can on
copying objects, I just seem to miss the point. I have
a class that is a collection of NSStrings with setters
and getters..
in the header
NSString *fName;
- (NSString *)fName;
- (void)setFName:(NSString *)aFName;
@implementation Person
//
=======================================================
// - fName:
//
=======================================================
- (NSString *)fName { return fName; }
//
======================================================
// - setFName:
//
=======================================================
- (void)setFName:(NSString *)aFName
{
if (fName != aFName) {
[fName release];
fName = [aFName retain];
}
}
@end
so that in the Controller class I am creating a person
currentPerson = [[Person alloc] init];
what I want to do is...
duplicateOfPerson = [currentPerson copy];
I want a deep copy. I want to alter a variable in
currentPerson and then compare that variable to
duplicateOfPerson to see what was changed (if
anything).
What I get is a shallow copy. If I change something in
currentPerson, that change follows into
duplicateOfPerson.
I guess I could just create a method that allocs
another Person and then uses the setter methods to
populate the variables. But I thought I would use a
'copy'.
I have been reading all the docs but I just don't get
it.
Thanks for the help.
Ted
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
_______________________________________________
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.