History details view: Create only one time the date formatter

This commit is contained in:
Yann Diorcet 2012-08-23 15:45:18 +02:00
parent 60055f2e7e
commit 4ae532b61a
2 changed files with 15 additions and 6 deletions

View file

@ -26,6 +26,7 @@
@interface HistoryDetailsViewController : UIViewController<UICompositeViewDelegate> {
@private
ABRecordRef contact;
NSDateFormatter *dateFormatter;
}
@property (nonatomic, retain) IBOutlet UIImageView *avatarImage;
@property (nonatomic, retain) IBOutlet UILabel *addressLabel;

View file

@ -38,9 +38,23 @@
#pragma mark - LifeCycle Functions
- (id)init {
self = [super initWithNibName:@"HistoryDetailsViewController" bundle:[NSBundle mainBundle]];
if(self != nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSLocale *locale = [NSLocale currentLocale];
[dateFormatter setLocale:locale];
}
return self;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[dateFormatter release];
[avatarImage release];
[addressLabel release];
[dateLabel release];
@ -221,13 +235,7 @@ static UICompositeViewDescription *compositeDescription = nil;
// Date
NSDate *startData = [NSDate dateWithTimeIntervalSince1970:callLog->start_date_time];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSLocale *locale = [NSLocale currentLocale];
[dateFormatter setLocale:locale];
[dateLabel setText:[dateFormatter stringFromDate:startData]];
[dateFormatter release];
// Duration
int duration = callLog->duration;