Re: Today is messed up
Re: Today is messed up
- Subject: Re: Today is messed up
- From: Peter Fischer <email@hidden>
- Date: Sun, 10 Aug 2003 08:46:09 -0400
Wesley -
In this example, you should never send today a release message
because of the way that you are creating the today variable. Sending
NSCalendarDate the calendarDate message returns a fully allocated &
initialized NSCalendarDate* object. This is a class method for the
NSCalendarDate, so all the memory management is handled for you by
NSCalendarDate. As a general rule, if you do not pass an object an
alloc, retain, or copy message, you should not be releasing it.
--Pete
On Sunday, August 10, 2003, at 04:58 AM, Wesley Penner wrote:
Hi,
I'm having trouble with this bit of code. Can anyone explain why?
- (int)setupDates {
int way;
NSCalendarDate *today = [NSCalendarDate calendarDate];
[today years:NULL months:NULL days:&way hours:NULL minutes:NULL
seconds:NULL sinceDate:startDate]; // <-- debugger stops here
way++;
....
[today release]; // <-- is this really necessary? Added when the
problems started to try and circumvent them
}
The first time through it performs as expected, assigning way to be the
number of days since startDate (set elsewhere). However, when I reset
startDate and call this a second time, it ends with "EXC_BAD_ACCESS".
(By the by, what does that mean anyway? I found no reference in the
documentation.)
The debugger shows that within the variable today there is a problem:
*((((((today)->isa)->cache)->buckets)[0]->method_types) [-[Controller
setupDates]0-Thread-1] :: out of scope
I have no idea what it means, so it sounds very impressive. How can I
fix this?
Thanks in advance for any insight you can offer,
Wesley Penner
_______________________________________________
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.
_______________________________________________
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.