将文件复制到系统文件夹/包
我正在做一个更改 Mac OSX 中垃圾桶图标的应用程序...到目前为止我得到了:
- (IBAction)install:(id)sender {
NSLog(@"Installing..");
NSLog(@"Trying to move file..");
NSString* src = @"/Users/myuser/Desktop/dashboard.png";
NSString* target = @"/System/Library/CoreServices/Dock/Contents/Resources/tester123.png";
NSError* error = nil;
[[NSFileManager defaultManager] copyItemAtPath:src toPath:target error:&error];
if (error) {
NSLog(@"%@", error);
NSLog(@"%@", [error userInfo]);
}
}
我收到错误:
The operation couldn’t be completed. No such file or directory
我相信这是因为 Dock 不是一个普通文件夹,而是一个包?我该如何解决这个问题?或者有更好的方法来更改垃圾图标吗?
I'm doing an app that changes the Trash-icon in Mac OSX... so far I got:
- (IBAction)install:(id)sender {
NSLog(@"Installing..");
NSLog(@"Trying to move file..");
NSString* src = @"/Users/myuser/Desktop/dashboard.png";
NSString* target = @"/System/Library/CoreServices/Dock/Contents/Resources/tester123.png";
NSError* error = nil;
[[NSFileManager defaultManager] copyItemAtPath:src toPath:target error:&error];
if (error) {
NSLog(@"%@", error);
NSLog(@"%@", [error userInfo]);
}
}
I'm getting the error:
The operation couldn’t be completed. No such file or directory
I believe it's because that Dock isnt a normal folder, but a package? How do I work around this? Or is there a better way to change the trash-icon?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将您的目标更改为此(Dock 变为 Dock.app):
您需要管理权限,否则您会收到此错误:
此命令在终端中运行完美(结论:路径正确)。
Change your target to this (Dock becomes Dock.app):
You need administrative rights, otherwise you get this error:
This command works perfect in Terminal (conclusion: the path is correct).