1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
kiran
  • 4,285
  • 7
  • 53
  • 98

1 Answers1

1

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]];
Krunal
  • 1,318
  • 1
  • 13
  • 31
  • 1
    As posted here: http://stackoverflow.com/questions/5032541/nspredicate-endswith-multiple-files/5032607#5032607 – Rengers Oct 22 '12 at 12:28