I'd like to programmatically set the Finder label (a.k.a. the color of items in the Finder) from within Cocoa. I can read the Finder label of a URL u
without problems using
MDItemRef itemRef = MDItemCreateWithURL(NULL, (CFURLRef)u);
CFStringRef s = MDItemCopyAttribute(itemRef, kMDItemFSLabel);
label = [(NSString *)s intValue];
This API does not provide any mechanism for writing the metadata, so my guess is that the solution lies elsewhere entirely. Any hints?
Edit: I know this is possible using AppleScript, but this is disallowed under sandboxing. I need a pure in-process solution.