• 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: 'Build and Analyze' with XCODE 3.2.2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Build and Analyze' with XCODE 3.2.2


  • Subject: Re: 'Build and Analyze' with XCODE 3.2.2
  • From: Nick Zitzmann <email@hidden>
  • Date: Sat, 24 Apr 2010 14:29:51 -0600

On Apr 24, 2010, at 2:02 PM, John Love wrote:

> Here's a sample snippet of my code:
>
> - (NSDate *)offsetDate:(NSDate *)fromDate
>                       byYears:(int)addYears
>                       byMonths:(int)addMonths
>                       byDays:(int)addDays {
>
> 	NSDateComponents *offset = [[NSDateComponents alloc] init];
> 	[offset setYear:addYears];
> 	[offset setMonth:addMonths];
> 	[offset setDay:addDays];
>
> 	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
> 	return [gregorian dateByAddingComponents:offset toDate:fromDate options:0];
>
> }
>
>
> Builds and runs just dandy .. but "Build and Analyze" coughs up:
>
> 	// method returns an object with a +1 retain count (owning reference)
> 	NSDateComponents *offset = [[NSDateComponents alloc] init];
>
> ... and at the end of the method:
>
> 	// object allocated and stored into 'offset' is no longer referenced after this point
> 	// and has a retain count of +1 (object leaked)
> 	}

I don't understand what you're trying to say. The static analyzer is telling you the truth, because you are leaking two objects in that code, unless that code will only be run with GC enabled.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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

References: 
 >'Build and Analyze' with XCODE 3.2.2 (From: John Love <email@hidden>)

  • Prev by Date: 'Build and Analyze' with XCODE 3.2.2
  • Next by Date: Re: 'Build and Analyze' with XCODE 3.2.2
  • Previous by thread: 'Build and Analyze' with XCODE 3.2.2
  • Next by thread: Re: 'Build and Analyze' with XCODE 3.2.2
  • Index(es):
    • Date
    • Thread