• 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
NSCalendarDate loses retain count.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSCalendarDate loses retain count.


  • Subject: NSCalendarDate loses retain count.
  • From: Brant Vasilieff <email@hidden>
  • Date: Thu, 25 Oct 2001 23:47:09 -0700

I'm trying to track down a bus_error, and noticed that a date that I was attempting to release has a retain count of zero, which makes it look suspect. However, I need to see when the date goes to zero, but that is getting tricky to track down because the retain count for NSCalendarDates appears to be off by one.

Calling [[NSCalendarDate alloc] init] or [NSCalendarDate calendarDate] both return calendar dates with a refCount of zero. Yet the calendar date appears to be on an autorelease pool, because if I retain the date, it still loses its retain count when the autorelease pool2 cleans up.

Check out initedCalendarDate and retainedCalendarDate2 in the following test case.


#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool1 = [[NSAutoreleasePool alloc] init];

NSCalendarDate* initedCalendarDate;
NSCalendarDate* retainedCalendarDate1;
NSCalendarDate* retainedCalendarDate2;

{
NSAutoreleasePool * pool2 = [[NSAutoreleasePool alloc] init];

initedCalendarDate = [[NSCalendarDate alloc] init];
retainedCalendarDate1 = [[NSCalendarDate calendarDate] retain];

retainedCalendarDate2 = [NSCalendarDate calendarDate];
[[retainedCalendarDate2 retain] retain];

[pool2 release];
}

[initedCalendarDate release];
[retainedCalendarDate1 release];
[retainedCalendarDate2 release];
[retainedCalendarDate2 release];

[pool1 release];
return 0;
}

TIA,
Brant


  • Prev by Date: Re: File Path -> FSSpec?
  • Next by Date: Re: Subclassing NSTableView
  • Previous by thread: Re: File Path -> FSSpec?
  • Next by thread: NSBezierPath with RoundRect?
  • Index(es):
    • Date
    • Thread