Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

objective c - Where's the iPhone MIME type database?

I have a program for the iPhone that is supposed to be doing intelligent things (picking out appropriate icons for file types) given a list of filenames. I'm looking for the iPhone take on something like /etc/mime.types or something similar- an API call is what I'm assuming would be available for the phone. Does this exist?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If it did, your app surely wouldn't have permissions to even read it directly. What are you trying to do?

EDIT

This is a function I wrote a while ago. I wrote it for the Mac, but it looks like the same functions exist on the iPhone. Basically, you give it a filename, and it uses the path extension to return the file's MIME type:

#import <MobileCoreServices/MobileCoreServices.h>
...
- (NSString*) fileMIMEType:(NSString*) file {
    CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[file pathExtension], NULL);
    CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
    CFRelease(UTI);
    return [(NSString *)MIMEType autorelease];
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...