Intermediary checkin, just to mark my place and back up, in case Panther decides...
[ITFoundation.git] / ITCategory-NSArray.m
diff --git a/ITCategory-NSArray.m b/ITCategory-NSArray.m
new file mode 100755 (executable)
index 0000000..6303a5f
--- /dev/null
@@ -0,0 +1,42 @@
+#import "ITCategory-NSArray.h"
+
+
+@implementation NSArray (ITCategory)
+
+- (NSArray *)objectsForKey:(NSString *)key
+{
+    NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:[self count]] autorelease];
+    NSEnumerator *enumerator = [self objectEnumerator];
+    id anItem;
+    
+    while ( (anItem = [enumerator nextObject]) ) {
+    
+        id itemObject = [anItem objectForKey:key];
+        
+        if ( itemObject ) {
+            [array addObject:itemObject];
+        } else {
+            [array addObject:[NSNull null]];
+        }
+    }
+    
+    return array;
+}
+
+- (BOOL)containsString:(NSString *)string
+{
+    NSEnumerator *enumerator = [self objectEnumerator];
+    id anItem;
+    BOOL result = NO;
+    
+    while ( (anItem = [enumerator nextObject]) ) {
+        
+        if ( ([[anItem class] isEqual:[NSString class]]) && [anItem isEqualToString:string] ) {
+            result = YES;
+        }
+    }
+
+    return result;
+}
+
+@end