• 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: Debugging retainCount
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging retainCount


  • Subject: Re: Debugging retainCount
  • From: The Amazing Llama <email@hidden>
  • Date: Wed, 16 Jul 2003 08:22:41 -0700

On Wednesday, July 16, 2003, at 07:19 AM, Brent Gulanowski wrote:
On Wednesday, July 16, 2003, at 02:09 AM, The Amazing Llama wrote:
Alright, if it's so easy, why does this code fail? I've been staring at it for a day now.

- (void)drawRect:(NSRect)rect {
NSCalendarDate* currentTick = [[self startDate] copy];

(retaincount+)

NSCalendarDate* nextTick;

while ([currentTick isLessThanOrEqualTo:[self endDate]]) {
NSRectFill(NSMakeRect([self xForDate:currentTick]-1, 0, 2, 10));

nextTick = [currentTick
dateByAddingYears:10 months:0
days:0 hours:0 minutes:0 seconds:0];
[currentTick release];
(retaincount-)
currentTick = [nextTick retain];
(retaincount+)
}
[currentTick release];
(retaincount-)
}

After this code, currentTick gets autoreleased.

What do you mean it "gets" autoreleased? It was already sent an autorelease message when you instantiated it with dateByAddingYears:... Have you sent an additional autorelease message, or are you stating the known fact that it gets released when the current autorelease pool gets released?

I mean the autorelease pool sends it the pending release message. That's when it crashes. Since I never deal with these variables outside of this code snippet, I am very confused about that.

Seth A. Roby The Amazing Llama < mail or AIM me at tallama at mac dot com>
"Life is like an exploded clown. It's really funny until you figure out what just happened."
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Debugging retainCount
      • From: publiclook <email@hidden>
    • Re: Debugging retainCount
      • From: publiclook <email@hidden>
References: 
 >Re: Debugging retainCount (From: Brent Gulanowski <email@hidden>)

  • Prev by Date: Re: Debugging retainCount
  • Next by Date: Running Java/Obj-C code with NSAppleScript
  • Previous by thread: Re: Debugging retainCount
  • Next by thread: Re: Debugging retainCount
  • Index(es):
    • Date
    • Thread