discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setter Gettor method style


From: Yen-Ju Chen
Subject: Re: Setter Gettor method style
Date: Sat, 03 Aug 2002 09:07:32 -0400

 There is an article on stepwise talking about that:
 http://www.stepwise.com/Articles/Technical/2002-06-11.01.html/
 Maybe it helps.
 Some macros in GNUstep can minimize the typing,
 like ASSIGN, TEST_RELEASE.

 Yen-Ju Chen

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




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx




reply via email to

[Prev in Thread] Current Thread [Next in Thread]