내 응용 프로그램 번들에서 내 응용 프로그램의 문서 디렉토리로 파일을 복사하려고합니다. "Cocoa Error 262"오류가 발생합니다. 내가 도대체 뭘 잘못하고있는 겁니까?여기에 내 사본에 문제가 있습니까?
이NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreData.sqlite"];
NSURL *initialURL = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"CoreData" ofType:@"sqlite"]];
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:[initialURL absoluteString]]) {
NSLog(@"Original does not exist. \nPath: %@", [initialURL absoluteString]);
}
if (![[NSFileManager defaultManager] fileExistsAtPath:[storeURL absoluteString]]) {
NSLog(@"Destination file does not exist. \nPath: %@", [storeURL absoluteString]);
[[NSFileManager defaultManager] copyItemAtURL:initialURL toURL:storeURL error:&error];
NSLog(@"Error: %@", [error description]);
}
올바른 계획은 무엇이며 어디에서이 정보를 얻었습니까? – Moshe
전체 "file : /// path/to/file"경로를 빌드하지 않으려면 + URLWithString :을 사용하지 마십시오. 그러나 당신이 + fileURLWithPath 일 때 당신은 왜 그렇게 할 것입니까? – kperryua
[link] (http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html)에서 정보를 얻었습니다. 올바른 구성표는 URL이 얼마나 중요한지를 의미합니다. 형식이 지정됩니다. – smitec