Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Sample Code :</strong></p> <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSArray *directory = [[NSFileManager defaultManager] directoryContentsAtPath: documentsDirectory]; BOOL isDirectory; for (NSString *item in directory){ BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:item isDirectory:&amp;isDirectory]; if (fileExistsAtPath) { if (isDirectory) { //It's a Directory. } } if ([[item pathExtension] isEqualToString:@"png"]) { //This is Image File with .png Extension } } </code></pre> <hr> <p>You can also use <a href="http://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html" rel="noreferrer"><strong>Uniform Type Identifiers</strong></a> as explained by <strong>Bavarious</strong> <a href="https://stackoverflow.com/a/5815629/1603072">here</a>. </p> <p><strong>Sample Code :</strong></p> <pre><code>NSString *file = @"…"; // path to some file CFStringRef fileExtension = (CFStringRef) [file pathExtension]; CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL); if (UTTypeConformsTo(fileUTI, kUTTypeImage)) NSLog(@"It's an image"); else if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) NSLog(@"It's a movie"); else if (UTTypeConformsTo(fileUTI, kUTTypeText)) NSLog(@"It's text"); CFRelease(fileUTI); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload