Re: A quick one: Passing a reference/pointer to NSString
Re: A quick one: Passing a reference/pointer to NSString
- Subject: Re: A quick one: Passing a reference/pointer to NSString
- From: Ken Thomases <email@hidden>
- Date: Tue, 22 Jul 2008 21:19:47 -0500
On Jul 22, 2008, at 9:07 PM, Graham Cox wrote:
- (void) leakLikeABastard:(NSString**) aString
{
*aString = @"new string";
}
There's nothing about returning an object pointer by reference that's
inherently prone to leaking. The more likely problem is in the caller
of such a method. If the caller supplies the address of a variable
which already holds a strong reference to an object, then passing that
variable by reference to this method would cause the caller to lose
track of its pointer. It would thus be unable to later release its
strong reference, causing a leak.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden