diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 8f57636f..2e38e53d 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -843,9 +843,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou id nodeResolver = [NSApp targetForAction:@selector(currentTargetNodes)]; - NSArray *targetNodes = [nodeResolver currentTargetNodes]; - NSArray *targetGroups = [groupResolver currentTargetGroups]; - NSArray *targetEntries = [entryResolver currentTargetEntries]; + NSArray *targetNodes = nodeResolver.currentTargetNodes; + NSArray *targetGroups = groupResolver.currentTargetGroups; + NSArray *targetEntries = entryResolver.currentTargetEntries; KPKEntry *targetEntry = targetEntries.count == 1 ? targetEntries.firstObject : nil; KPKGroup *targetGroup = targetGroups.count == 1 ? targetGroups.firstObject : nil; diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 343b8e3a..990a991c 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -388,7 +388,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); - (void)createGroup:(id)sender { id target = [NSApp targetForAction:@selector(currentTargetGroups)]; - NSArray *groups = [target currentTargetGroups]; + NSArray *groups = target.currentTargetGroups; MPDocument *document = self.document; if(groups.count == 1) { [document createGroup:groups.firstObject]; @@ -400,7 +400,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); - (void)createEntry:(id)sender { id target = [NSApp targetForAction:@selector(currentTargetGroups)]; - NSArray *groups = [target currentTargetGroups]; + NSArray *groups = target.currentTargetGroups; if(groups.count == 1) { [(MPDocument *)self.document createEntry:groups.firstObject]; } @@ -408,7 +408,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); - (void)delete:(id)sender { id target = [NSApp targetForAction:@selector(currentTargetNodes)]; - NSArray *nodes = [target currentTargetNodes]; + NSArray *nodes = target.currentTargetNodes; for(KPKNode *node in nodes) { [self.document deleteNode:node]; } @@ -460,7 +460,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); - (void)performAutotypeForEntry:(id)sender { id entryResolver = [NSApp targetForAction:@selector(currentTargetEntries)]; - NSArray *entries = [entryResolver currentTargetEntries]; + NSArray *entries = entryResolver.currentTargetEntries; if(entries.count == 1) { [[MPAutotypeDaemon defaultDaemon] performAutotypeForEntry:entries.firstObject]; } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 79ec99ec..33bbc01e 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -409,7 +409,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (NSArray *)currentTargetNodes { - NSArray *entries = [self currentTargetEntries]; + NSArray *entries = self.currentTargetEntries; if(entries.count > 0) { return entries; } @@ -641,7 +641,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; #pragma mark Actions - (void)copyPassword:(id)sender { - NSArray *nodes = [self currentTargetNodes]; + NSArray *nodes = self.currentTargetNodes; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; NSString *value = [selectedEntry.password kpk_finalValueForEntry:selectedEntry]; if(value) { @@ -650,7 +650,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)copyUsername:(id)sender { - NSArray *nodes = [self currentTargetNodes]; + NSArray *nodes = self.currentTargetNodes; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; NSString *value = [selectedEntry.username kpk_finalValueForEntry:selectedEntry]; if(value) { @@ -659,7 +659,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)copyCustomAttribute:(id)sender { - NSArray *nodes = [self currentTargetNodes]; + NSArray *nodes = self.currentTargetNodes; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; if(selectedEntry && [selectedEntry isKindOfClass:[KPKEntry class]]) { NSUInteger index = [sender tag]; @@ -673,7 +673,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)copyURL:(id)sender { - NSArray *nodes = [self currentTargetNodes]; + NSArray *nodes = self.currentTargetNodes; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; NSString *value = [selectedEntry.url kpk_finalValueForEntry:selectedEntry]; if(value) { @@ -711,7 +711,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)delete:(id)sender { - NSArray *entries = [self currentTargetEntries]; + NSArray *entries = self.currentTargetEntries; MPDocument *document = self.windowController.document; for(KPKEntry *entry in entries) { [document deleteNode:entry]; @@ -720,7 +720,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; - (void)revertToHistoryEntry:(id)sender { MPDocument *document = self.windowController.document; - NSArray *historyEntries = [self currentTargetEntries]; + NSArray *historyEntries = self.currentTargetEntries; if(historyEntries.count != 1) { return; } diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index cf00cba6..c0813617 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -197,7 +197,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } - (NSArray *)currentTargetNodes { - NSArray *groups = [self currentTargetGroups]; + NSArray *groups = self.currentTargetGroups; if(groups.count > 0) { return groups; } @@ -221,7 +221,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; return; // Nothing we need to worry about } MPDocument *document = self.windowController.document; - document.selectedGroups = [self currentTargetGroups]; + document.selectedGroups = self.currentTargetGroups; } - (void)_outlineDidScroll:(NSNotification *)notification { @@ -233,7 +233,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; CGPoint point = CGPointMake(clipView.bounds.origin.x, clipView.bounds.origin.y + 11); NSInteger topRow = [self.outlineView rowAtPoint:point]; id item = [[self.outlineView itemAtRow:topRow] representedObject]; - if([item isKindOfClass:[KPKGroup class]]) { + if([item isKindOfClass:KPKGroup.class]) { KPKGroup *group = item; MPDocument *document = self.windowController.document; document.tree.metaData.lastTopVisibleGroup = group.uuid; @@ -309,14 +309,14 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; - (void)outlineViewSelectionDidChange:(NSNotification *)notification { MPDocument *document = self.windowController.document; - NSArray *groups = [self currentTargetGroups]; + NSArray *groups = self.currentTargetGroups; /* only update state if binding is set up to prevent resetting on first show */ if(_bindingEstablished) { NSUUID *oldValue = document.tree.metaData.lastSelectedGroup; document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID kpk_nullUUID]); NSUUID *newVlaue = document.tree.metaData.lastSelectedGroup; if(![oldValue isEqual:newVlaue]) { - [document updateChangeCount:NSChangeDone|NSChangeDiscardable]; + [document updateChangeCount:NSChangeDone|NSChangeDiscardable]; } } document.selectedGroups = groups; @@ -359,7 +359,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; if(![document validateUserInterfaceItem:menuItem]) { return NO; } - KPKGroup *group = [self currentTargetNodes].firstObject.asGroup; + KPKGroup *group = self.currentTargetNodes.firstObject.asGroup; return group.isTrash && group.isTrashed; } diff --git a/MacPass/MPTargetNodeResolving.h b/MacPass/MPTargetNodeResolving.h index cb1ae5ea..39b13595 100644 --- a/MacPass/MPTargetNodeResolving.h +++ b/MacPass/MPTargetNodeResolving.h @@ -28,8 +28,8 @@ @protocol MPTargetNodeResolving @optional -- (NSArray *)currentTargetNodes; -- (NSArray *)currentTargetGroups; -- (NSArray *)currentTargetEntries; +@property (nonatomic, readonly, copy) NSArray *currentTargetNodes; +@property (nonatomic, readonly, copy) NSArray *currentTargetGroups; +@property (nonatomic, readonly, copy) NSArray *currentTargetEntries; @end