diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index c09eb7a7..b5700d77 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -460,6 +460,7 @@ 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+Humanized.m"; sourceTree = ""; }; 4C13904C17ADD1A300A62934 /* KPKTreeCrypting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKTreeCrypting.h; sourceTree = ""; }; 4C13904D17ADD3BE00A62934 /* KPKTreeWriting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKTreeWriting.h; sourceTree = ""; }; + 4C13C3CF1B7241550085C291 /* KPKIconTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKIconTypes.h; sourceTree = ""; }; 4C15B74518BCA3B1003F8008 /* MPDocument+Search.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Search.m"; sourceTree = ""; }; 4C17D8E317A1C780006C8C1E /* MPDocumentWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentWindowDelegate.h; sourceTree = ""; }; 4C17D8E417A1C780006C8C1E /* MPDocumentWindowDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentWindowDelegate.m; sourceTree = ""; }; @@ -1173,6 +1174,7 @@ 4C0104BF17C37DFC00173EF3 /* KPKTypes.h */, 4CC6DB7B17D23DCE002C6091 /* KPKUTIs.h */, 4CC6DB7C17D23DCE002C6091 /* KPKUTIs.m */, + 4C13C3CF1B7241550085C291 /* KPKIconTypes.h */, ); path = Utilites; sourceTree = ""; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 6e71521c..e4cd5e31 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -541,7 +541,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey if(group == self.trash) { return; //Group is trash! } - [group moveToGroup:self.trash atIndex:[self.trash.groups count]]; + [group moveToGroup:self.trash]; [[self undoManager] setActionName:NSLocalizedString(@"TRASH_GROUP", "Move Group to Trash")]; } else { diff --git a/MacPass/MPIconHelper.m b/MacPass/MPIconHelper.m index d7e07d41..72011410 100644 --- a/MacPass/MPIconHelper.m +++ b/MacPass/MPIconHelper.m @@ -28,17 +28,17 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSDictionary *imageNames = [MPIconHelper availableIconNames]; - NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]]; + NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:imageNames.count]; - NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { - return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]]; + NSArray *sortedImageNames = [imageNames.allKeys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { + return [imageNames[obj1] compare:imageNames[obj2]]; }]; for(NSNumber *iconNumber in sortedImageNames) { - if([iconNumber integerValue] > MPCustomIconTypeBegin) { + if(iconNumber.integerValue > MPCustomIconTypeBegin) { continue; // Skip all non-db Keys } - MPIconType iconType = (MPIconType)[iconNumber integerValue]; + MPIconType iconType = (MPIconType)iconNumber.integerValue; [mutableIcons addObject:[MPIconHelper icon:iconType]]; } icons = [mutableIcons copy]; @@ -52,19 +52,14 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSDictionary *imageNames = [MPIconHelper availableIconNames]; - NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]]; NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]]; }]; - - for(NSNumber *iconNumber in sortedImageNames) { - if([iconNumber integerValue] > MPCustomIconTypeBegin) { - continue; // Skip all non-db Keys - } - [mutableIcons addObject:iconNumber]; - } - iconTypes = [mutableIcons copy]; + iconTypes = [sortedImageNames filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { + NSNumber *iconNumber = (NSNumber *)evaluatedObject; + return (iconNumber.integerValue < MPCustomIconTypeBegin); + }]]; }); return iconTypes; } diff --git a/MacPass/MPIconSelectViewController.m b/MacPass/MPIconSelectViewController.m index e28372b1..56bea1b0 100644 --- a/MacPass/MPIconSelectViewController.m +++ b/MacPass/MPIconSelectViewController.m @@ -41,10 +41,10 @@ NSInteger const kMPDefaultIcon = -1; - (void)didLoadView { //[[self.imageButton cell] setBackgroundStyle:NSBackgroundStyleLowered]; - [self.iconCollectionView setBackgroundColors:@[[NSColor clearColor]]]; - [self.iconCollectionView setSelectable:YES]; - [self.iconCollectionView setAllowsMultipleSelection:NO]; - [self.iconCollectionView setContent:[MPIconHelper databaseIcons]]; + self.iconCollectionView.backgroundColors = @[[NSColor clearColor]]; + self.iconCollectionView.selectable = YES; + self.iconCollectionView.allowsMultipleSelection = NO; + self.iconCollectionView.content = [MPIconHelper databaseIcons]; } - (IBAction)useDefault:(id)sender { @@ -66,9 +66,9 @@ NSInteger const kMPDefaultIcon = -1; - (IBAction)_selectImage:(id)sender { self.didCancel = NO; NSButton *button = sender; - NSImage *image = [button image]; - NSUInteger buttonIndex = [[self.iconCollectionView content] indexOfObject:image]; - self.selectedIcon = [[MPIconHelper databaseIconTypes] [buttonIndex] integerValue]; + NSImage *image = button.image; + NSUInteger buttonIndex = [self.iconCollectionView.content indexOfObject:image]; + self.selectedIcon = ((NSNumber *)[MPIconHelper databaseIconTypes][buttonIndex]).integerValue; [self.popover performClose:self]; }