IOSAD-172 Can sort passphrase entries newest to oldest IOSAD-172
authorDirk Zimmermann <dz@pep.security>
Mon, 29 Jun 2020 16:39:43 +0200
branchIOSAD-172
changeset 1535b5796927e5b6
parent 1534 49cd42b330f5
child 1536 ad798e1af91e
IOSAD-172 Can sort passphrase entries newest to oldest
pEpObjCAdapter/PEPPassphraseCache.m
     1.1 --- a/pEpObjCAdapter/PEPPassphraseCache.m	Mon Jun 29 16:39:43 2020 +0200
     1.2 +++ b/pEpObjCAdapter/PEPPassphraseCache.m	Mon Jun 29 16:39:43 2020 +0200
     1.3 @@ -151,4 +151,21 @@
     1.4      return NO;
     1.5  }
     1.6  
     1.7 +- (NSArray<PEPPassphraseCacheEntry *> *)sortedArrayByDateNewestFirst:(NSArray<PEPPassphraseCacheEntry *> *)array
     1.8 +{
     1.9 +    return [array sortedArrayUsingComparator:^NSComparisonResult(PEPPassphraseCacheEntry *entry1,
    1.10 +                                                                 PEPPassphraseCacheEntry *entry2) {
    1.11 +        NSTimeInterval interval1 = [entry1.dateAdded timeIntervalSinceReferenceDate];
    1.12 +        NSTimeInterval interval2 = [entry2.dateAdded timeIntervalSinceReferenceDate];
    1.13 +
    1.14 +        if (interval1 > interval2) {
    1.15 +            return NSOrderedAscending;
    1.16 +        } else if (interval1 < interval2) {
    1.17 +            return NSOrderedDescending;
    1.18 +        } else {
    1.19 +            return NSOrderedSame;
    1.20 +        }
    1.21 +    }];
    1.22 +}
    1.23 +
    1.24  @end