Fixed #93. Formatter are now cleaned up on reused table cell views

This commit is contained in:
michael starke
2013-10-21 19:11:39 +02:00
parent 89105c6e90
commit 620be11f0d

View File

@@ -242,28 +242,36 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
} }
else { else {
view = [tableView makeViewWithIdentifier:_MPTableStringCellView owner:self]; view = [tableView makeViewWithIdentifier:_MPTableStringCellView owner:self];
if(isURLColumn) { NSTextField *textField = [view textField];
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"url" options:nil]; if(!isModifedColumn && !isNotesColumn) {
/* clean up old formatter that might be left */
NSLog(@"Cleaing formatter. %@", [textField formatter]);
[textField setFormatter:nil];
} }
else if(isUsernameColumn) { if(isModifedColumn) {
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"username" options:nil]; if(![[view textField] formatter]) {
}
else if(isNotesColumn) {
NSDictionary *options = @{ NSValueTransformerNameBindingOption : MPStripLineBreaksTransformerName };
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"notes" options:options];
}
else if(isAttachmentColumn) {
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"binaries.@count" options:nil];
}
else if(isModifedColumn) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateFormatterMediumStyle];
[[view textField] setFormatter:formatter]; [textField setFormatter:formatter];
[[view textField] bind:NSValueBinding toObject:entry.timeInfo withKeyPath:@"lastModificationTime" options:nil]; }
[textField bind:NSValueBinding toObject:entry.timeInfo withKeyPath:@"lastModificationTime" options:nil];
return view;
}
else if(isURLColumn) {
[textField bind:NSValueBinding toObject:entry withKeyPath:@"url" options:nil];
}
else if(isUsernameColumn) {
[textField bind:NSValueBinding toObject:entry withKeyPath:@"username" options:nil];
}
else if(isNotesColumn) {
NSDictionary *options = @{ NSValueTransformerNameBindingOption : MPStripLineBreaksTransformerName };
[textField bind:NSValueBinding toObject:entry withKeyPath:@"notes" options:options];
}
else if(isAttachmentColumn) {
[textField bind:NSValueBinding toObject:entry withKeyPath:@"binaries.@count" options:nil];
} }
} }
return view; return view;
} }