Re: Alloc/dealloc etiquette
David Phillip Oster <[email protected]> Sat, 17 Feb 2007 20:00:10 GMT
| Newsgroups | gmane.comp.lib.gnustep.user |
|---|---|
| Organization | SBC http://yahoo.sbc.com |
| Message-ID | <[email protected]> |
In article <[email protected]>, David Phillip Oster <[email protected]> wrote: > In article <[email protected]>, > Sherm Pendley <[email protected]> wrote: > > > - (void)setFoo:(NSObject *)value { > > if (foo != value) { > > [foo release]; > > foo = [value copy]; > > } > > } Apologies. I was assuming a matching: - (NSObject *)foo{ return foo; } But, if you always write: - (NSObject *)foo{ return [[foo copy] autorelease]; } then my "swap" criticism doesn't apply. However, I often want access to an object's part, not a transient copy of the part. (When I pull a puppet's string, connected to its finger, I expect the finger to move, not a copy of the finger, which is then immediately thrown away.)