Sha256: 6aecc49fc06dd4acf8a2ac7d5375d8ae7d5126ea6b9ed029d2c2a0453ce82eb9

Contents?: true

Size: 739 Bytes

Versions: 60

Compression:

Stored size: 739 Bytes

Contents

#import <Foundation/Foundation.h>
#import "StrainExample.h"

NS_ASSUME_NONNULL_BEGIN

@implementation NSArray (StrainExample)

-(instancetype)keep:(BOOL)compare where:(BOOL (^)(id))completionHandler{
    
    NSMutableArray *filteredArray = [NSMutableArray array];
    
    for(int index = 0;index < self.count;index++){
        
        id objectInArray = self[index];
        
        BOOL flag = completionHandler(objectInArray);
        
        if(flag == compare){
            
            [filteredArray addObject:objectInArray];
        }
    }
    
    return filteredArray;
    
}

-(instancetype)discard:(BOOL (^)(id))completionHandler{
    
    return [self keep:false where:completionHandler];
}


@end

NS_ASSUME_NONNULL_END

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.158 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.157 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.156 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.155 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.154 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.153 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.152 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.151 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.150 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.149 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.148 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.147 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.146 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.145 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.144 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.143 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.142 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.141 tracks/objective-c/exercises/strain/StrainExample.m
trackler-2.2.1.140 tracks/objective-c/exercises/strain/StrainExample.m