NSFileManager moveItemAtPath issue

萝らか妹 提交于 2019-12-13 06:35:33

问题


I am using NSFileManager to move items from one file path to another file path but it results in an exception.But i dont get exception every time, the exception is raised only after second or third time of loading the urls

Exception Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x631a900 {NSUserStringVariant=Move, NSFilePath=/Users/cgvak/Library/Application Support/iPhone Simulator/4.3/Applications/3731EEFB-03F8-4E0B-BF5D-A94BEE0D2DE2/Library/Caches/imgcache//loading/http:__www.sankar.com.au_sankar_property_photo_2010_09_30_dc4a35f82ee70002604f6c06fd811f9d_m.jpg, NSDestinationFilePath=/Users/cgvak/Library/Application Support/iPhone Simulator/4.3/Applications/3731EEFB-03F8-4E0B-BF5D-A94BEE0D2DE2/Library/Caches/imgcache//ready/http:__www.sankar.com.au_sankar_property_photo_2010_09_30_dc4a35f82ee70002604f6c06fd811f9d_m.jpg}

What should i do in order to overcome from this problem?Please any body help me to overcome from this problem.

Thanks in advance.


回答1:


Have you checked that the path exists? also there is an // in the file path. Try to remove that one.

Could you also post you code, with out code we really have to guess.

The Cocoa error 4 means that you are trying to move a file that does not exist, this could also mean that the target directory does not exists.




回答2:


Please Check NSSearchPathDirectory

Instead

NSArray * paths=NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);

Write This

NSArray * paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);


来源:https://stackoverflow.com/questions/6895078/nsfilemanager-moveitematpath-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!