Using modern Objective-C syntac

This commit is contained in:
michael starke
2015-07-15 14:40:53 +02:00
parent cc68a57914
commit a75e5c7e2f
2 changed files with 68 additions and 69 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPEntryViewController"> <customObject id="-2" userLabel="File's Owner" customClass="MPEntryViewController">
@@ -26,10 +26,11 @@
<rect key="frame" x="0.0" y="17" width="694" height="548"/> <rect key="frame" x="0.0" y="17" width="694" height="548"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" rowSizeStyle="automatic" headerView="676" viewBased="YES" id="55" customClass="MPTableView"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" rowSizeStyle="automatic" headerView="676" viewBased="YES" id="55" customClass="MPTableView">
<rect key="frame" x="0.0" y="0.0" width="693" height="0.0"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/> <size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns> <tableColumns>
<tableColumn identifier="Group Column" width="104.609375" minWidth="40" maxWidth="3.4028234663852886e+38" id="117"> <tableColumn identifier="Group Column" width="104.609375" minWidth="40" maxWidth="3.4028234663852886e+38" id="117">
@@ -50,7 +51,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="270"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="270">
<rect key="frame" x="1" y="0.0" width="102.5" height="17"/> <rect key="frame" x="1" y="0.0" width="102" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="271"> <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="271">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -136,7 +137,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="429" customClass="NSSecureTextField"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="429" customClass="NSSecureTextField">
<rect key="frame" x="1" y="0.0" width="116.5" height="17"/> <rect key="frame" x="1" y="0.0" width="116" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="430"> <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="430">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -260,7 +261,7 @@
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
</buttonCell> </buttonCell>
</button> </button>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uCV-75-BFs"> <textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uCV-75-BFs">
<rect key="frame" x="324" y="8" width="46" height="14"/> <rect key="frame" x="324" y="8" width="46" height="14"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="infotext" id="GLC-co-PAD"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="infotext" id="GLC-co-PAD">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
@@ -291,6 +292,6 @@
</objects> </objects>
<resources> <resources>
<image name="NSActionTemplate" width="14" height="14"/> <image name="NSActionTemplate" width="14" height="14"/>
<image name="NSAddTemplate" width="8" height="8"/> <image name="NSAddTemplate" width="11" height="11"/>
</resources> </resources>
</document> </document>

View File

@@ -134,10 +134,10 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
[_bottomBar setBorderType:HNHBorderTop|HNHBorderHighlight]; [_bottomBar setBorderType:HNHBorderTop|HNHBorderHighlight];
[self.addEntryButton setAction:[MPActionHelper actionOfType:MPActionAddEntry]]; [self.addEntryButton setAction:[MPActionHelper actionOfType:MPActionAddEntry]];
[self.entryTable setDelegate:self]; self.entryTable.delegate = self;
[self.entryTable setDoubleAction:@selector(_columnDoubleClick:)]; self.entryTable.doubleAction = @selector(_columnDoubleClick:);
[self.entryTable setTarget:self]; self.entryTable.target = self;
[self.entryTable setFloatsGroupRows:NO]; self.entryTable.floatsGroupRows = NO;
[self.entryTable registerForDraggedTypes:@[KPKEntryUTI]]; [self.entryTable registerForDraggedTypes:@[KPKEntryUTI]];
/* First responder notifications */ /* First responder notifications */
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
@@ -146,55 +146,51 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
object:_entryTable]; object:_entryTable];
[self _setupEntryMenu]; [self _setupEntryMenu];
NSTableColumn *parentColumn = [self.entryTable tableColumns][0]; NSTableColumn *parentColumn = self.entryTable.tableColumns[0];
NSTableColumn *titleColumn = [self.entryTable tableColumns][1]; NSTableColumn *titleColumn = self.entryTable.tableColumns[1];
NSTableColumn *userNameColumn = [self.entryTable tableColumns][2]; NSTableColumn *userNameColumn = self.entryTable.tableColumns[2];
NSTableColumn *passwordColumn = [self.entryTable tableColumns][3]; NSTableColumn *passwordColumn = self.entryTable.tableColumns[3];
NSTableColumn *urlColumn = [self.entryTable tableColumns][4]; NSTableColumn *urlColumn = self.entryTable.tableColumns[4];
NSTableColumn *attachmentsColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableAttachmentColumnIdentifier]; NSTableColumn *attachmentsColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableAttachmentColumnIdentifier];
NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier]; NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier];
NSTableColumn *modifiedColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableModfiedColumnIdentifier]; NSTableColumn *modifiedColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableModfiedColumnIdentifier];
[notesColumn setMinWidth:40.0]; notesColumn.minWidth = 40.0;
[attachmentsColumn setMinWidth:40.0]; attachmentsColumn.minWidth = 40.0;
[modifiedColumn setMinWidth:40.0]; modifiedColumn.minWidth = 40.0;
[self.entryTable addTableColumn:notesColumn]; [self.entryTable addTableColumn:notesColumn];
[self.entryTable addTableColumn:attachmentsColumn]; [self.entryTable addTableColumn:attachmentsColumn];
[self.entryTable addTableColumn:modifiedColumn]; [self.entryTable addTableColumn:modifiedColumn];
[parentColumn setIdentifier:MPEntryTableParentColumnIdentifier]; parentColumn.identifier = MPEntryTableParentColumnIdentifier;
[titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier]; titleColumn.identifier = MPEntryTableTitleColumnIdentifier;
[userNameColumn setIdentifier:MPEntryTableUserNameColumnIdentifier]; userNameColumn.identifier = MPEntryTableUserNameColumnIdentifier;
[passwordColumn setIdentifier:MPEntryTablePasswordColumnIdentifier]; passwordColumn.identifier = MPEntryTablePasswordColumnIdentifier;
[urlColumn setIdentifier:MPEntryTableURLColumnIdentifier]; urlColumn.identifier = MPEntryTableURLColumnIdentifier;
self.entryTable.autosaveName = @"EntryTable";
self.entryTable.autosaveTableColumns = YES;
[self.entryTable setAutosaveName:@"EntryTable"];
[self.entryTable setAutosaveTableColumns:YES];
NSString *parentNameKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(name))]; NSString *parentNameKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(name))];
NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(title))ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(username)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(url)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:parentNameKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:[MPEntryViewController timeInfoModificationTimeKeyPath] ascending:YES selector:@selector(compare:)];
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor]; titleColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(title))ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor]; userNameColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(username)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
[urlColumn setSortDescriptorPrototype:urlSortDescriptor]; urlColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector(@selector(url)) ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
[parentColumn setSortDescriptorPrototype:groupnameSortDescriptor]; parentColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:parentNameKeyPath ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
[modifiedColumn setSortDescriptorPrototype:dateSortDescriptor]; modifiedColumn.sortDescriptorPrototype = [NSSortDescriptor sortDescriptorWithKey:[MPEntryViewController timeInfoModificationTimeKeyPath] ascending:YES selector:@selector(compare:)];
[[parentColumn headerCell] setStringValue:NSLocalizedString(@"GROUP", "")]; [parentColumn.headerCell setStringValue:NSLocalizedString(@"GROUP", "")];
[[titleColumn headerCell] setStringValue:NSLocalizedString(@"TITLE", "")]; [titleColumn.headerCell setStringValue:NSLocalizedString(@"TITLE", "")];
[[userNameColumn headerCell] setStringValue:NSLocalizedString(@"USERNAME", "")]; [userNameColumn.headerCell setStringValue:NSLocalizedString(@"USERNAME", "")];
[[passwordColumn headerCell] setStringValue:NSLocalizedString(@"PASSWORD", "")]; [passwordColumn.headerCell setStringValue:NSLocalizedString(@"PASSWORD", "")];
[[urlColumn headerCell] setStringValue:NSLocalizedString(@"URL", "")]; [urlColumn.headerCell setStringValue:NSLocalizedString(@"URL", "")];
[[notesColumn headerCell] setStringValue:NSLocalizedString(@"NOTES", "")]; [notesColumn.headerCell setStringValue:NSLocalizedString(@"NOTES", "")];
[[attachmentsColumn headerCell] setStringValue:NSLocalizedString(@"ATTACHMENTS", "")]; [attachmentsColumn.headerCell setStringValue:NSLocalizedString(@"ATTACHMENTS", "")];
[[modifiedColumn headerCell] setStringValue:NSLocalizedString(@"MODIFIED", "")]; [modifiedColumn.headerCell setStringValue:NSLocalizedString(@"MODIFIED", "")];
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(arrangedObjects)) options:nil]; [self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(arrangedObjects)) options:nil];
[self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(sortDescriptors)) options:nil]; [self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:NSStringFromSelector(@selector(sortDescriptors)) options:nil];
[self.entryTable setDataSource:_dataSource]; self.entryTable.dataSource = self.dataSource;
// bind NSArrayController sorting so that sort order gets auto-saved // bind NSArrayController sorting so that sort order gets auto-saved
// see: http://simx.me/technonova/software_development/sort_descriptors_nstableview_bindings_a.html // see: http://simx.me/technonova/software_development/sort_descriptors_nstableview_bindings_a.html
@@ -204,7 +200,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
options:@{ NSValueTransformerNameBindingOption: NSUnarchiveFromDataTransformerName }]; options:@{ NSValueTransformerNameBindingOption: NSUnarchiveFromDataTransformerName }];
[self _setupHeaderMenu]; [self _setupHeaderMenu];
[parentColumn setHidden:YES]; parentColumn.hidden = YES;
} }
- (NSResponder *)reconmendedFirstResponder { - (NSResponder *)reconmendedFirstResponder {
@@ -256,14 +252,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
BOOL isTitleColumn = [[tableColumn identifier] isEqualToString:MPEntryTableTitleColumnIdentifier]; BOOL isTitleColumn = [tableColumn.identifier isEqualToString:MPEntryTableTitleColumnIdentifier];
BOOL isGroupColumn = [[tableColumn identifier] isEqualToString:MPEntryTableParentColumnIdentifier]; BOOL isGroupColumn = [tableColumn.identifier isEqualToString:MPEntryTableParentColumnIdentifier];
BOOL isPasswordColum = [[tableColumn identifier] isEqualToString:MPEntryTablePasswordColumnIdentifier]; BOOL isPasswordColum = [tableColumn.identifier isEqualToString:MPEntryTablePasswordColumnIdentifier];
BOOL isUsernameColumn = [[tableColumn identifier] isEqualToString:MPEntryTableUserNameColumnIdentifier]; BOOL isUsernameColumn = [tableColumn.identifier isEqualToString:MPEntryTableUserNameColumnIdentifier];
BOOL isURLColumn = [[tableColumn identifier] isEqualToString:MPEntryTableURLColumnIdentifier]; BOOL isURLColumn = [tableColumn.identifier isEqualToString:MPEntryTableURLColumnIdentifier];
BOOL isAttachmentColumn = [[tableColumn identifier] isEqualToString:MPEntryTableAttachmentColumnIdentifier]; BOOL isAttachmentColumn = [tableColumn.identifier isEqualToString:MPEntryTableAttachmentColumnIdentifier];
BOOL isNotesColumn = [[tableColumn identifier] isEqualToString:MPEntryTableNotesColumnIdentifier]; BOOL isNotesColumn = [tableColumn.identifier isEqualToString:MPEntryTableNotesColumnIdentifier];
BOOL isModifedColumn = [[tableColumn identifier] isEqualToString:MPEntryTableModfiedColumnIdentifier]; BOOL isModifedColumn = [tableColumn.identifier isEqualToString:MPEntryTableModfiedColumnIdentifier];
NSTableCellView *view = nil; NSTableCellView *view = nil;
if(isTitleColumn || isGroupColumn) { if(isTitleColumn || isGroupColumn) {
@@ -275,8 +271,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
NSString *iconImageKeyPath = [NSString stringWithFormat:@"%@.%@", NSString *iconImageKeyPath = [NSString stringWithFormat:@"%@.%@",
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(iconImage))]; NSStringFromSelector(@selector(iconImage))];
[[view textField] bind:NSValueBinding toObject:view withKeyPath:titleKeyPath options:nil]; [view.textField bind:NSValueBinding toObject:view withKeyPath:titleKeyPath options:nil];
[[view imageView] bind:NSValueBinding toObject:view withKeyPath:iconImageKeyPath options:nil]; [view.imageView bind:NSValueBinding toObject:view withKeyPath:iconImageKeyPath options:nil];
} }
else { else {
KPKEntry *entry = [self.entryArrayController arrangedObjects][row]; KPKEntry *entry = [self.entryArrayController arrangedObjects][row];
@@ -290,8 +286,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(parent)), NSStringFromSelector(@selector(parent)),
NSStringFromSelector(@selector(iconImage))]; NSStringFromSelector(@selector(iconImage))];
[[view textField] bind:NSValueBinding toObject:view withKeyPath:parentNameKeyPath options:nil]; [view.textField bind:NSValueBinding toObject:view withKeyPath:parentNameKeyPath options:nil];
[[view imageView] bind:NSValueBinding toObject:view withKeyPath:parentIconImageKeyPath options:nil]; [view.imageView bind:NSValueBinding toObject:view withKeyPath:parentIconImageKeyPath options:nil];
} }
} }
else if(isPasswordColum) { else if(isPasswordColum) {
@@ -300,17 +296,16 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(password))]; NSStringFromSelector(@selector(password))];
NSDictionary *options = @{ NSValueTransformerBindingOption : [NSValueTransformer valueTransformerForName:MPStringLengthValueTransformerName] }; NSDictionary *options = @{ NSValueTransformerBindingOption : [NSValueTransformer valueTransformerForName:MPStringLengthValueTransformerName] };
[[view textField] bind:NSValueBinding toObject:view withKeyPath:passwordKeyPath options:options]; [view.textField bind:NSValueBinding toObject:view withKeyPath:passwordKeyPath options:options];
} }
else { else {
view = [tableView makeViewWithIdentifier:_MPTableStringCellView owner:self]; view = [tableView makeViewWithIdentifier:_MPTableStringCellView owner:self];
NSTextField *textField = [view textField];
if(!isModifedColumn) { if(!isModifedColumn) {
/* clean up old formatter that might be left */ /* clean up old formatter that might be left */
[textField setFormatter:nil]; view.textField.formatter = nil;
} }
if(isModifedColumn) { if(isModifedColumn) {
if(![[view textField] formatter]) { if(!view.textField.formatter) {
/* Just use one formatter instance since it's expensive to create */ /* Just use one formatter instance since it's expensive to create */
static NSDateFormatter *formatter = nil; static NSDateFormatter *formatter = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
@@ -319,38 +314,41 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
[formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateFormatterMediumStyle];
}); });
[textField setFormatter:formatter]; view.textField.formatter = formatter;
} }
NSString *modificatoinTimeKeyPath = [NSString stringWithFormat:@"%@.%@.%@", NSString *modificatoinTimeKeyPath = [NSString stringWithFormat:@"%@.%@.%@",
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(timeInfo)),
NSStringFromSelector(@selector(lastModificationTime))]; NSStringFromSelector(@selector(lastModificationTime))];
[textField bind:NSValueBinding toObject:view withKeyPath:modificatoinTimeKeyPath options:nil]; [view.textField bind:NSValueBinding toObject:view withKeyPath:modificatoinTimeKeyPath options:nil];
return view; return view;
} }
else if(isURLColumn) { else if(isURLColumn) {
NSString *urlKeyPath = [NSString stringWithFormat:@"%@.%@", NSString *urlKeyPath = [NSString stringWithFormat:@"%@.%@",
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(url))]; NSStringFromSelector(@selector(url))];
[textField bind:NSValueBinding toObject:view withKeyPath:urlKeyPath options:nil]; [view.textField bind:NSValueBinding toObject:view withKeyPath:urlKeyPath options:nil];
} }
else if(isUsernameColumn) { else if(isUsernameColumn) {
NSString *usernameKeyPath = [NSString stringWithFormat:@"%@.%@", NSString *usernameKeyPath = [NSString stringWithFormat:@"%@.%@",
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(username))]; NSStringFromSelector(@selector(username))];
[textField bind:NSValueBinding toObject:view withKeyPath:usernameKeyPath options:nil]; [view.textField bind:NSValueBinding toObject:view withKeyPath:usernameKeyPath options:nil];
} }
else if(isNotesColumn) { else if(isNotesColumn) {
NSDictionary *options = @{ NSValueTransformerNameBindingOption : MPStripLineBreaksTransformerName }; NSDictionary *options = @{ NSValueTransformerNameBindingOption : MPStripLineBreaksTransformerName };
NSString *notesKeyPath = [NSString stringWithFormat:@"%@.%@", NSString *notesKeyPath = [NSString stringWithFormat:@"%@.%@",
NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(notes))]; NSStringFromSelector(@selector(notes))];
[textField bind:NSValueBinding toObject:view withKeyPath:notesKeyPath options:options]; [view.textField bind:NSValueBinding toObject:view withKeyPath:notesKeyPath options:options];
} }
else if(isAttachmentColumn) { else if(isAttachmentColumn) {
[textField bind:NSValueBinding toObject:view withKeyPath:@"objectValue.binaries.@count" options:nil]; NSString *binariesCoundKeyPath = [NSString stringWithFormat:@"%@.%@.@count",
NSStringFromSelector(@selector(objectValue)),
NSStringFromSelector(@selector(binaries))];
[view.textField bind:NSValueBinding toObject:view withKeyPath:binariesCoundKeyPath options:nil];
} }
} }
return view; return view;