WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / macosx / NSArray+HBAdditions.m
blobbabcc9f15a6996d7fd0dd692a533e0c0af7f4d62
1 //
2 //  NSArray+NSArray_HBArrayAdditions.m
3 //  HandBrake
4 //
5 //  Created by Damiano Galassi on 22/07/15.
6 //
7 //
9 #import "NSArray+HBAdditions.h"
11 @implementation NSMutableArray (HBAdditions)
13 - (void)removeObjectsUsingBlock:(BOOL (^)(id object))block
15     NSMutableArray *objectsToRemove = [NSMutableArray array];
16     for (id object in self)
17     {
18         if (block(object))
19         {
20             [objectsToRemove addObject:object];
21         }
22     }
23     [self removeObjectsInArray:objectsToRemove];
26 @end
28 @implementation NSArray (HBAdditions)
30 - (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id object))block
32     NSMutableArray *filteredArray = [NSMutableArray array];
33     for (id object in self)
34     {
35         if (block(object))
36         {
37             [filteredArray addObject:object];
38         }
39     }
40     return [filteredArray copy];
43 - (NSIndexSet *)indexesOfObjectsUsingBlock:(BOOL (^)(id object))block
45     NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
46     NSUInteger i = 0;
47     for (id object in self)
48     {
49         if (block(object))
50         {
51             [indexes addIndex:i];
52         }
53         i++;
54     }
55     return [indexes copy];
58 @end