Last active
August 29, 2015 14:06
-
-
Save quellish/14ad2315fc4a8cc2dabd to your computer and use it in GitHub Desktop.
Method for getting an array of MIME types for images that ImageIO and UIKit can understand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import ImageIO; | |
| @import MobileCoreServices; | |
| + (NSArray *) imageMIMETypes { | |
| NSArray *result = nil; | |
| NSMutableArray *mimeTypes = nil; | |
| NSArray *typeIdentifiers = nil; | |
| typeIdentifiers = (__bridge_transfer NSArray*)CGImageSourceCopyTypeIdentifiers(); | |
| mimeTypes = [[NSMutableArray alloc] init]; | |
| for (NSString *type in typeIdentifiers){ | |
| NSString *MIMETypeString = nil; | |
| MIMETypeString = CFBridgingRelease(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)type, kUTTagClassMIMEType)); | |
| if ([MIMETypeString length] > 0){ | |
| [mimeTypes addObject:MIMETypeString]; | |
| } | |
| } | |
| result = [mimeTypes copy]; | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment