xcodeのリソースグループにplistファイルがあります。アプリの起動時にこれをドキュメントディレクトリにコピーしようとしています。私は次のコードを使用しています(sqliteチュートリアルから取得):
BOOL success;
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingString:@"ActiveFeedsPlist.plist"];
success = [fileManager fileExistsAtPath:filePath];
if (success) return;
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingFormat:@"ActiveFeedsPlist.plist"];
success = [fileManager copyItemAtPath:path toPath:filePath error:&error];
if (!success) {
NSAssert1(0, @"Failed to copy Plist. Error %@", [error localizedDescription]);
}
エラー「***キャッチされない例外のためにアプリを終了します'NSInternalInconsistencyException'、理由:'Plistのコピーに失敗しました。エラー操作を完了できませんでした。そのようなファイルまたはディレクトリはありません'」というエラーがコンソールに表示されます。
何が悪いのか分かりますか?
ありがとう