Re: It doesn't work without the NSLog()... Why?
Re: It doesn't work without the NSLog()... Why?
- Subject: Re: It doesn't work without the NSLog()... Why?
- From: Graham Cox <email@hidden>
- Date: Wed, 29 Apr 2009 22:32:41 +1000
On 29/04/2009, at 10:05 PM, Тимофей Даньшин wrote:
NSArray *ret = [mutableRet copy];
// NSLog(@"The number of items to be returned is: %i", [ret count]);
[mutableRet release];
return ret;
I don't see why your NSLog line should cause a problem, but your
memory management at the end of the function is wrong, so may have a
bearing on it.
Why copy mutableRet when you just release it anyway? Instead, just
return it with an autorelease:
return [mutableRet autorelease];
There is no need to copy a mutable array just so you can return it as
a non-mutable array - it is an array and its mutability is invisible
to the client of this code. As it stands you're leaking the copy
because it is never released.
--Graham
_______________________________________________
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