kiran
kiran

Reputation: 4409

How to get the file extension

How to give multiple check condition in NSPredicate

[NSPredicate predicateWithFormat:@"SELF ENDSWITH %@ %@%@ ,doc,pdf,png];

it need to work and give me three type and give me output.

Upvotes: 1

Views: 115

Answers (1)

Krunal
Krunal

Reputation: 1328

Try this....

NSArray *ext = [NSArray arrayWithObjects:@"doc", @"pdf", @"png", nil];
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirPath error:nil];
NSArray *files = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"pathExtension IN %@", ext]];

Upvotes: 1

Related Questions