user1312508
user1312508

Reputation: 183

Image file extension Xcode

I'm programming an app similar to the email. So when I attach a file to my message I would like to show the filename + small image (icon), this icon should be according the filetype, for example pdf if the file is a pdf, Word id the file is a word file ....

Anyone know how can I find these small images ? Or any representative example ?

Advanced thank

Upvotes: 1

Views: 403

Answers (1)

Martin R
Martin R

Reputation: 539685

If this is for iOS then you can use UIDocumentInteractionController:

NSURL *url = [NSURL fileURLWithPath:pathToYourFile];
UIDocumentInteractionController *diac = [UIDocumentInteractionController interactionControllerWithURL:url];
NSArray *icons = diac.icons;
if ([icons count] > 0) {
    // This is the smallest available icon:
    UIImage *icon = [icons objectAtIndex:0];
} else {
    // No icon found.
    // According to the documentation, this case *should not* occur...
}

Upvotes: 2

Related Questions