Re: Today is messed up
Re: Today is messed up
- Subject: Re: Today is messed up
- From: Jonathan Jackel <email@hidden>
- Date: Sun, 10 Aug 2003 10:30:09 -0400
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
}
Don't release what you don't own. You don't own today.
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.)
It means you are trying to access an object that has been deallocated.
(man signal has more info.)
There are two objects in the line of code where the debugger stops:
today and startDate. You just acquired the reference to today and you
haven't done anything that can make today go away (like releasing it)
so you can be very confident today is not your problem.
You are probably not retaining startDate, or releasing it prematurely.
How are you creating it? What else do you do with it between the first
run and the second?
Jonathan
_______________________________________________
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.