Where's the iPhone MIME type database?

后端 未结 4 1762
太阳男子
太阳男子 2020-12-02 10:36

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 t

4条回答
  •  时光说笑
    2020-12-02 11:38

    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 
    ...
    - (NSString*) fileMIMEType:(NSString*) file {
        CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[file pathExtension], NULL);
        CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
        CFRelease(UTI);
        return [(NSString *)MIMEType autorelease];
    }
    

提交回复
热议问题