• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: It doesn't work without the NSLog()... Why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: It doesn't work without the NSLog()... Why?
      • From: Тимофей Даньшин <email@hidden>
References: 
 >It doesn't work without the NSLog()... Why? (From: Тимофей Даньшин <email@hidden>)

  • Prev by Date: Re: It doesn't work without the NSLog()... Why?
  • Next by Date: Re: NSRunLoop vs. NSThread sleep
  • Previous by thread: Re: It doesn't work without the NSLog()... Why?
  • Next by thread: Re: It doesn't work without the NSLog()... Why?
  • Index(es):
    • Date
    • Thread