Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for contains to NSSet and NSOrderedSet

  • Loading branch information...
commit 85818e038bd96ae4c9880080a4424fa77478b272 1 parent 837e6eb
Tyler Bindon martica authored
11 Kiwi/KWHamrestMatchingAdditions.h
View
@@ -23,3 +23,14 @@
@end
+@interface NSSet (KiwiHamcrestAdditions)
+
+- (BOOL)containsObjectEqualToOrMatching:(id)object;
+
+@end
+
+@interface NSOrderedSet (KiwiHamcrestAdditions)
+
+- (BOOL)containsObjectEqualToOrMatching:(id)object;
+
+@end
24 Kiwi/KWHamrestMatchingAdditions.m
View
@@ -46,4 +46,28 @@ - (BOOL)containsObjectMatching:(id<HCMatcher>)matcher
@end
+@implementation NSSet (KiwiHamcrestAdditions)
+
+- (BOOL)containsObjectEqualToOrMatching:(id)object
+{
+ if ([object conformsToProtocol:@protocol(HCMatcher)]) {
+ return [[self allObjects] containsObjectMatching:object];
+ }
+ return [self containsObject:object];
+}
+
+@end
+
+@implementation NSOrderedSet (KiwiHamcrestAdditions)
+
+- (BOOL)containsObjectEqualToOrMatching:(id)object
+{
+ if ([object conformsToProtocol:@protocol(HCMatcher)]) {
+ return [[self array] containsObjectMatching:object];
+ }
+ return [self containsObject:object];
+}
+
+@end
+
Please sign in to comment.
Something went wrong with that request. Please try again.