I’m having a lot of issues with NSDate objects being prematurely deallocated. I suspect that the issues may be related to the way that I deal with the objects returned from NSDate convenience methods. I think that my showDate property declaration in the JKShow class should be ‘retain’, but changing it to assign or copy seems to have no effect on the issue.
JKShow *show; NSDate *date; NSMutableArray *list = [[NSMutableArray alloc] init]; // Show 1 show = [[JKShow alloc] init]; //... date = [gregorian dateFromComponents:dateComponents]; show.showDate = date; [list addObject:[show autorelease]]; // Show 2 show = [[JKShow alloc] init]; //... date = [gregorian dateFromComponents:dateComponents]; show.showDate = date; [list addObject:[show autorelease]];
UPDATE
The issue was not in the code copied here. In my JKShow init method I was not retaining the date returned from the NSDate convenience method. Thanks for your help, everyone.
I figured it out, thanks for all your help, but the problem was outside of the code I posted here. I was not retaining the
NSDateI created in my init method. Unfortunatly the crash didn’t occur until after I had created the two newNSDateobjects, so I was totally barking up the wrong tree.