In other dynamic languages like ruby, javascript etc. you can do simply this:
switch(someString) {
case \"foo\":
//do something;
break;
cas
NSString * extension = [fileName pathExtension];
NSString * directory = nil;
NSUInteger index = [@[@"txt",@"png",@"caf",@"mp4"] indexOfObjectPassingTest:^
BOOL(id obj, NSUInteger idx, BOOL *stop)
{
return [obj isEqualToString:extension];
}];
switch (index)
{
case 0:
directory = @"texts/";
break;
case 1:
directory = @"images/";
break;
case 2:
directory = @"sounds/";
break;
case 3:
directory = @"videos/";
break;
default:
@throw [NSException exceptionWithName:@"unkonwnFileFormat"
reason:[NSString stringWithFormat:@"zip file contain nknown file format: %@",fileName]
userInfo:nil];
break;
}