【发布时间】:2012-01-17 09:30:37
【问题描述】:
我想刷新 Finder 应用程序中特定文件/文件夹的图标。
FNNotifyByPath( (const UInt8 *)folderPath, kFNDirectoryModifiedMessage, kNilOptions );
FNNotifyByPath 不适用于此。
现在我正在尝试使用 appleScript
+(void) refreshIconForItem : (NSString *)itemPath
{
NSString *source=[NSString stringWithFormat:@"tell application \"Finder\" to update \"%@\"",[NSString stringWithUTF8String:itemPath]];
NSAppleScript *update=[[NSAppleScript alloc] initWithSource:source];
NSDictionary *err;
[update executeAndReturnError:&err];
}
但是这个功能也不起作用。
谁能帮帮我?
【问题讨论】:
-
你找到这个解决方案了吗?请让我知道哪个脚本正在为此工作。因为我几乎使用了所有脚本,但不会使用任何脚本。任何帮助表示赞赏..!!
-
@Jigar 你可以使用stackoverflow.com/a/15541439/944634。 Finder 刷新苹果脚本不适用于 10.8 及更高版本
标签: objective-c cocoa applescript macos-carbon finder