From: Martin Häcker <mhaecker@mac.com>
To: discuss-gnustep@gnu.org
Subject: Re: Setter Gettor method style
Date: Sat, 3 Aug 2002 14:18:00 +0200
> - (void) setTitle: (NSString *)newTitle {
[title autorelease];
Here, there is not advantage to wait before releasing title. It's
owned by the object, it can be released directly. If anybody has been
interested in title it will have retained it long ago. Since title is
overwritten immediately, it cannot be retrieved after this statement,
so you can as well use release.
title = [newTitle copy];
// or retain, depending on object & usage
> }
:) I certainly don't want to question your wizardry, but as far as I
understand this this style was chosen because of something like this:
...
NSString *str = [myDocument title];
...
[myDocument setTitle:@"cool"];
...
NSLog(@"I've got a %@", str);
And the string should remain valid for the rest of the routine. (Perhaps
this also has something to do with OS X having no Garbage Collection)
Peace,
Martin
--
dont.wanna.tell
[ot]coder - hehe
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://mail.gnu.org/mailman/listinfo/discuss-gnustep