Mark, thanks. I realize after sending it that this is probably not exactly the correct forum, so I appreciate your input.
I guess, in a way, it follows the basic tenet that *if* the method/programmer does not "create" it, then it is not *my* responsibility to release it, and on a deeper level, as you point out, could in fact be detrimental.
Thanks again.
On Jan 24, 2010, at 7:06 AM, Mark Suman wrote: Whoever called insertText is responsible for making sure that the NSString "input" is released in an appropriate manner, whether explicitly or with an autorelease pool. You definitely shouldn't release it in the setString method, because "input" might need to be used for other things after it was passed to insertText.
Mark On Sun, Jan 24, 2010 at 7:57 AM, Michael de Haan <email@hidden> wrote: No...it's not a question about "the rules"! I know better than to ask that! :-)
On page 271 in Hillegass, (Typing tutor) a setter is defined thus:
-(void) setString:(NSString *) c { c = [c copy]; [string release]; string = c;
}
and "string" is subsequently released in the "dealloc" method.
The caller is the overridden method:
-(void) insertText:(NSString *)input { [self setString:input]; }
My question pertains the **original** object , which was referenced/passed to the method "setString".
Can I **assume** that the originally referenced object is released in an appropriate way, once the copy is created and assigned to "c"?
|