equal
deleted
inserted
replaced
36 -(void) viewDidLoad { |
36 -(void) viewDidLoad { |
37 [super viewDidLoad]; |
37 [super viewDidLoad]; |
38 |
38 |
39 NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FORTS_DIRECTORY() error:NULL]; |
39 NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FORTS_DIRECTORY() error:NULL]; |
40 NSMutableArray *filteredContents = [[NSMutableArray alloc] initWithCapacity:([directoryContents count] / IMGNUM_PER_FORT)]; |
40 NSMutableArray *filteredContents = [[NSMutableArray alloc] initWithCapacity:([directoryContents count] / IMGNUM_PER_FORT)]; |
41 // we need to remove the double entries and the L.png suffix |
41 // we assume here that fort's images has one image with the 'L.png' suffix and we remove this suffix to get the correct name |
42 for (NSUInteger i = 0; i < [directoryContents count]; i++) { |
42 for (NSUInteger i = 0; i < [directoryContents count]; i++) |
43 if (i % IMGNUM_PER_FORT == IMGNUM_PER_FORT-1) { |
43 { |
44 NSString *currentName = [directoryContents objectAtIndex:i]; |
44 NSString *currentName = [directoryContents objectAtIndex:i]; |
45 NSString *correctName = [currentName substringToIndex:([currentName length] - 5)]; |
45 if ([currentName rangeOfString:@"L.png"].location != NSNotFound) |
|
46 { |
|
47 NSString *correctName = [currentName stringByReplacingOccurrencesOfString:@"L.png" withString:@""]; |
46 [filteredContents addObject:correctName]; |
48 [filteredContents addObject:correctName]; |
47 } |
49 } |
48 } |
50 } |
49 self.fortArray = filteredContents; |
51 self.fortArray = filteredContents; |
50 [filteredContents release]; |
52 [filteredContents release]; |