Cocoa - NSFileManager removeItemAtPath不工作 [英] Cocoa - NSFileManager removeItemAtPath Not Working

查看:871
本文介绍了Cocoa - NSFileManager removeItemAtPath不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图删除一个文件,但不知何故nsfilemanager不会允许我这样做。我在一行代码中使用该文件,但一旦该行动已经运行,我想删除该文件。我记录了错误代码和消息,我收到错误代码:4和消息:

 text.txt删除

有没有办法修复这个错误干净



这是我正在使用的:



  [[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL]; 

感谢,



kevin

解决方案

错误代码4似乎是NSNoSuchFileError 。如果你想要删除的文件确实存在,那么你得到的路径错误。如果你想让我们准确地告诉你你的路径是怎么回事,你需要发布一些代码。



如果文件不存在,您可以忽略此错误。


I am trying to delete a file, but somehow nsfilemanager will not allow me to do so. I do use the file in one line of code, but once that action has been ran, I want the file deleted. I have logged the error code and message and I get error code: 4 and the message:

"text.txt" could not be removed

Is there a way to fix this error "cleanly" (without any hacks) so that apple will accept this app onto their Mac App Store?

EDIT:

This is what I am using:

[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];

Thanks,

kevin

解决方案

Error code 4 seems to be NSNoSuchFileError. If the file you want to delete really exists, then you have got the path wrong. You'll need to post some code if you want us to tell you exactly how you got the path wrong.

If the file doesn't exist, you can ignore the error.

这篇关于Cocoa - NSFileManager removeItemAtPath不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆