I have:
NSDate *d = [[NSDate alloc] init];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *dc = [calendar components:unitFlags fromDate:d];
// doing something with dc.day, dc.month, dc.year
[dc release];
[d release];
I’ve tried removing the “doing something.. part”, just did a get and release, and it still crashes.
If I just comment out the [dc release] part, it all works fine.
I’m new to Obj-C. Any idea why this crashes?
Am I doing something wrong?
You shouldn’t be releasing
dc. It does not come from an alloc, new, or copy.Brush up on the Cocoa Memory Management Rules