我有适用于 IOS 5.1 的 iPad 应用程序,现在我正在尝试为 6.0 构建它,但出现错误:
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,
原因:-[NSFileManager copyItemAtPath:toPath:error:]: source path is nil'”
我发现这个问题在哪里,但我不知道如何纠正它
在我的AppDelegate
-(void)copyFileWithName:(NSString*)name Extension:(NSString*)extension ToDir:(NSString*)dirName withName:(NSString*)newName
{
NSString *folderPath = dirName;
NSString *filePathDocTxt = [folderPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", newName, extension]];
NSString *filePathBundleTxt = [[NSBundle mainBundle] pathForResource:name ofType:extension];
//when i comment these two lines, my code compiles success, but i need these code
if(![[NSFileManager defaultManager] fileExistsAtPath:filePathDocTxt])
[[NSFileManager defaultManager] copyItemAtPath:filePathBundleTxt toPath:filePathDocTxt error:nil];
}