如何刷新取景器窗口?
我想刷新 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];
}
但这个功能也不起作用。
有人可以帮我吗?
I want to refresh icon for particular file/folder in Finder application.
FNNotifyByPath( (const UInt8 *)folderPath, kFNDirectoryModifiedMessage, kNilOptions );
FNNotifyByPath
is not working for this.
Now i am trying with 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];
}
but this function is also not working.
Can anyone please help me out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在
executeAndReturnError:
调用之后检查了err
字典的值?正确的 AppleScript 语法是:
编辑添加:或者,您可以下拉到AppleEvent级别:
Did you check the value of the
err
dictionary after theexecuteAndReturnError:
call?The correct AppleScript syntax would be:
EDIT TO ADD: Alternately, you could drop down to the AppleEvent level: