From cd925a81f3fa622fcd0ac35bbd265e7dee87c535 Mon Sep 17 00:00:00 2001 From: michael starke Date: Wed, 7 Oct 2015 15:54:17 +0200 Subject: [PATCH] using property syntax Signed-off-by: michael starke --- MacPass/MPDocument.m | 18 +++++++++--------- MacPass/MPEntryViewController.m | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 2248b4f0..63ac89a4 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -494,11 +494,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey } - (void)deleteNode:(KPKNode *)node { - if([node asGroup]) { - [self deleteGroup:[node asGroup]]; + if(node.asGroup) { + [self deleteGroup:node.asGroup]; } - else if([node asEntry]) { - [self deleteEntry:[node asEntry]]; + else if(node.asEntry) { + [self deleteEntry:node.asEntry]; } } @@ -554,7 +554,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey } - (void)_presentTrashAlertForItem:(KPKNode *)node { - KPKEntry *entry = [node asEntry]; + KPKEntry *entry = node.asEntry; NSAlert *alert = [[NSAlert alloc] init]; [alert setAlertStyle:NSWarningAlertStyle]; @@ -574,10 +574,10 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey if(returnCode == NSAlertFirstButtonReturn) { KPKNode *node = (__bridge KPKNode *)(contextInfo); /* No undo on this operation */ - for( KPKEntry *entry in [[node asGroup] childEntries]) { + for( KPKEntry *entry in node.asGroup.childEntries) { [node.undoManager removeAllActionsWithTarget:entry]; } - for(KPKGroup *group in [[node asGroup] childGroups]) { + for(KPKGroup *group in node.asGroup.childGroups) { [node.undoManager removeAllActionsWithTarget:group]; } [node remove]; @@ -640,10 +640,10 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey KPKGroup *targetGroup = [groupResolver currentTargetGroup]; /* - if([targetNode asGroup]) { + if(targetNode.asGroup) { NSLog(@"targetNode:%@", ((KPKGroup *)targetNode).name); } - else if([targetNode asEntry]) { + else if(targetNode.asEntry) { NSLog(@"targetNode:%@", ((KPKEntry *)targetNode).title); } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index dc004cf0..8f292ca6 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -650,21 +650,21 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; #pragma mark Actions - (void)copyPassword:(id)sender { - KPKEntry *selectedEntry = [[self currentTargetNode] asEntry]; + KPKEntry *selectedEntry = [self currentTargetNode].asEntry; if(selectedEntry) { [self _copyToPasteboard:[selectedEntry.password finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoPassword name:nil]; } } - (void)copyUsername:(id)sender { - KPKEntry *selectedEntry = [[self currentTargetNode] asEntry]; + KPKEntry *selectedEntry = [self currentTargetNode].asEntry; if(selectedEntry) { [self _copyToPasteboard:[selectedEntry.username finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoUsername name:nil]; } } - (void)copyCustomAttribute:(id)sender { - KPKEntry *selectedEntry = [[self currentTargetNode] asEntry]; + KPKEntry *selectedEntry = [self currentTargetNode].asEntry; if(selectedEntry && [selectedEntry isKindOfClass:[KPKEntry class]]) { NSUInteger index = [sender tag]; NSAssert((index >= 0) && (index < [selectedEntry.customAttributes count]), @"Index for custom field needs to be valid"); @@ -674,14 +674,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)copyURL:(id)sender { - KPKEntry *selectedEntry = [[self currentTargetNode] asEntry]; + KPKEntry *selectedEntry = [self currentTargetNode].asEntry; if(selectedEntry) { [self _copyToPasteboard:[selectedEntry.url finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoURL name:nil]; } } - (void)openURL:(id)sender { - KPKEntry *selectedEntry = [[self currentTargetNode] asEntry]; + KPKEntry *selectedEntry = [self currentTargetNode].asEntry; NSString *expandedURL = [selectedEntry.url finalValueForEntry:selectedEntry]; if(expandedURL.length > 0) { NSURL *webURL = [NSURL URLWithString:[expandedURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; @@ -707,7 +707,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)delete:(id)sender { - KPKEntry *entry = [[self currentTargetNode] asEntry]; + KPKEntry *entry = [self currentTargetNode].asEntry; if(!entry) { return; }