Huge update to ITFoundation. I've gone through every file (except queue.h
[ITFoundation.git] / ITCategory-NSArray.m
1 #import "ITCategory-NSArray.h"
2
3 @implementation NSArray (ITFoundationCategory)
4
5 - (NSArray *)objectsForKey:(NSString *)key {
6         NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:[self count]] autorelease];
7         NSEnumerator *enumerator = [self objectEnumerator];
8         id anItem;
9         
10         while ( (anItem = [enumerator nextObject]) ) {
11         
12                 id itemObject = [anItem objectForKey:key];
13                 
14                 if ( itemObject ) {
15                         [array addObject:itemObject];
16                 } else {
17                         [array addObject:[NSNull null]];
18                 }
19         }
20         
21         return array;
22 }
23
24 - (BOOL)containsString:(NSString *)string {
25         NSEnumerator *enumerator = [self objectEnumerator];
26         id anItem;
27         BOOL result = NO;
28         
29         while ( (anItem = [enumerator nextObject]) ) {
30                 
31                 if ( [anItem isEqual:string] ) {
32                         result = YES;
33                 }
34         }
35
36         return result;
37 }
38
39 @end