discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Setter Gettor method style


From: Alexander Malmberg
Subject: Re: Setter Gettor method style
Date: Sun, 04 Aug 2002 17:07:34 +0200

> > > >   - (NSString *) title {
> > > >        return [[title retain] autorelease];
> > >
> > > This is strictly equivalent to { return title; }
> >
> > This is not true. I've fixed bugs in Pantomime caused by this.
> >
> > - Alexander Malmberg
> 
> Agree.  But the case where the difference matter would not occur in my
> book because I have the rule to retain all objects I need:
> 
>      NSString* title=[[stuff title]retain];
>      [stuff setTitle:newTitle];
>      NSLog(@"old title was address@hidden",title);
>      [title release];
> 
> In my  little mind, it's simplier  to have simple rules  to be applied
> always without exceptions.

I agree, but I think the simple rule should be 'objects returned by
library code are autoreleased', with the possible exception of pure
container objects (eg. NSArray:s). Isn't one of the big points with
having the whole autorelease system that you're supposed to be able to
write 'sloppy' code and get away with it if you want to?

Anyway, whichever way it's supposed to be, it should be documented
somewhere.

> --
> __Pascal_Bourguignon__                   http://www.informatimago.com/
> ----------------------------------------------------------------------

- Alexander Malmberg



reply via email to

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