TableView - iVar reset when returning from details view

Posted by iFloh on Stack Overflow See other posts from Stack Overflow or by iFloh
Published on 2010-04-27T13:53:24Z Indexed on 2010/04/27 17:33 UTC
Read the original article Hit count: 312

Filed under:
|
|

Hi, anyone knows what I need to do to retain my TableView iVars whilst pushing a details view onto the navigation stack?

I have an array and a date defined as iVars and the array is retained, whilst the date is not. I checked whether there may be an autorelease hidden somewhere but there are no obvious ones.

The properties are defined as nonatomic, retain.

I use custom NSDate category methods to determine specific dates at stages. These use NSDateComponents, NSRange and NSCalendar, for example:

- (NSDate *)lastDayOfMonth: {
 NSCalendar *tmpCal = [NSCalendar currentCalendar];
 NSDateComponents *tmpDateComponents = [tmpCal components:NSYearCalendarUnit | NSMonthCalendarUnit | NSEraCalendarUnit | NSWeekCalendarUnit | NSWeekdayOrdinalCalendarUnit fromDate:self];
 NSRange tmpRange = [tmpCal rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:[tmpCal dateFromComponents:tmpDateComponents]];

 [tmpDateComponents setDay:tmpRange.length];
 [tmpDateComponents setHour:23];
 [tmpDateComponents setMinute:59];
 [tmpDateComponents setSecond:59];
 return [[NSCalendar currentCalendar] dateFromComponents:tmpDateComponents];
}

could they somehow be the reason?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone