• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Finder Tags API
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finder Tags API


  • Subject: Finder Tags API
  • From: Ben Staveley-Taylor <email@hidden>
  • Date: Tue, 11 Mar 2014 14:51:15 +0000

I’m trying to understand the Finder Tags APIs in Mavericks.

I would like to set a custom Finder Tag on a number of files, ensure it appears in the Finder sidebar tag set, and assign it a color so the user can gather the files easily in the Finder. My application is a file manager and moves files around, but never actually opens and saves them so the user cannot explicitly assign Tags in a save dialog.

Let’s say I want to use “My Tag” as the tag string. I can assign a tag like this:

    NSDictionary *dictTags = [item resourceValuesForKeys:[NSArray arrayWithObject:NSURLTagNamesKey] error:&error];
    NSArray *arrPreviousTags = [dictTags valueForKey:NSURLTagNamesKey];
    NSArray *arrNewTags = [arrPreviousTags arrayByAddingObject:@"My Tag"];
    [item setResourceValue:arrNewTags forKey:NSURLTagNamesKey error:&error];

then “My Tag” shows in the Finder tags list, but with no color. I can’t seem to find much by way of a Tags API other than the NSURL NSURLTagNamesKey resources.

How can I assign a color to the tag “My Tag”?

I’d even settle for always using the standard Red tag, for example, but I would need to check that it exists in case the user has changed the default Tag set. And it might have a different name in other localizations. Can I enumerate all the Finder Tags that are available? The NSWorkspace labels don’t seem to be the same thing:

       NSArray *possibleTags = [[NSWorkspace sharedWorkspace] fileLabels];

always returns: None, Gray, Green, Purple, Blue, Yellow, Red, Orange, i.e. not my custom tag, nor even the standard “Important”, “Home” or “Work”.

Thanks,

— Ben.

(PS: I made a similar post a week or so ago but I don’t think it ever got to the list. Apologies if anyone gets this twice.)


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Prev by Date: How to create a Tags selection field in a dialog
  • Next by Date: Saving while opening with NSDocument
  • Previous by thread: Re: How to create a Tags selection field in a dialog
  • Next by thread: Saving while opening with NSDocument
  • Index(es):
    • Date
    • Thread