On Jul 29, 2011, at 11:09 AM, Wade Tregaskis wrote:

> for (NSString *path in paths) {
>       NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
>       NSString *uti = nil;
>       NSError *error = nil;
> 
>       if ([url getResourceValue:&uti forKey:NSURLTypeIdentifierKey 
> error:&error]) {
>               for (NSString *supportedType in supportedTypes) {
>                       if (UTTypeConformsTo(uti, supportedType)) {
>                               // You have a match.
>                       }
>               }
>       } else {
>               // Handle error
>       }
> }
> 
> There's a lot of nasty enumeration there, rather than hashtables which make 
> me much happier, but I don't know of a better way off hand.
> 
> However, -[NSURL getResourceValue:forKey:error:] is only available in iOS 4.0 
> and later.  So you'll have to find another route if you're targeting earlier 
> than that.

Don't know about iOS, but on Mac OS X if you're starting with a file path, 
you're probably better of using -[NSWorkspace typeOfFile:error:] rather than 
going through NSURL.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to