summaryrefslogtreecommitdiffstats
path: root/macosx/NSArray+HBAdditions.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-07-22 07:46:07 +0000
committerritsuka <[email protected]>2015-07-22 07:46:07 +0000
commitbe9ac805c8fbc2c8ba37389ce034db92f15b7e4a (patch)
treef14e4803c1eca0e93c712941f2fed6bfeddd9125 /macosx/NSArray+HBAdditions.m
parent99d6dc51d695cce18c27b65fb42196a57a4c3eb7 (diff)
MacGui: various queue improvements, including:
- multiple items drag & drop - "reset job" in contextual menu item to reset the job state - a toolbar item to select the action to perform when the queue is done - useless animations. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7358 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/NSArray+HBAdditions.m')
-rw-r--r--macosx/NSArray+HBAdditions.m58
1 files changed, 58 insertions, 0 deletions
diff --git a/macosx/NSArray+HBAdditions.m b/macosx/NSArray+HBAdditions.m
new file mode 100644
index 000000000..babcc9f15
--- /dev/null
+++ b/macosx/NSArray+HBAdditions.m
@@ -0,0 +1,58 @@
+//
+// NSArray+NSArray_HBArrayAdditions.m
+// HandBrake
+//
+// Created by Damiano Galassi on 22/07/15.
+//
+//
+
+#import "NSArray+HBAdditions.h"
+
+@implementation NSMutableArray (HBAdditions)
+
+- (void)removeObjectsUsingBlock:(BOOL (^)(id object))block
+{
+ NSMutableArray *objectsToRemove = [NSMutableArray array];
+ for (id object in self)
+ {
+ if (block(object))
+ {
+ [objectsToRemove addObject:object];
+ }
+ }
+ [self removeObjectsInArray:objectsToRemove];
+}
+
+@end
+
+@implementation NSArray (HBAdditions)
+
+- (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id object))block
+{
+ NSMutableArray *filteredArray = [NSMutableArray array];
+ for (id object in self)
+ {
+ if (block(object))
+ {
+ [filteredArray addObject:object];
+ }
+ }
+ return [filteredArray copy];
+}
+
+- (NSIndexSet *)indexesOfObjectsUsingBlock:(BOOL (^)(id object))block
+{
+ NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
+ NSUInteger i = 0;
+ for (id object in self)
+ {
+ if (block(object))
+ {
+ [indexes addIndex:i];
+ }
+ i++;
+ }
+ return [indexes copy];
+}
+
+@end