はい、Ken さん、アプリを作成するとドキュメント ディレクトリがデフォルトで存在します。必要に応じて、そこからテキスト データを読み書きすることもできます。
Documents フォルダーにデータを直接ドロップすることはできませんが、プログラムで行う必要があります。
ファイルの 1 つが「TextFile1.txt」であるとします。最初にこのファイルをプロジェクトに追加し、appDelegate のどこかに次のコードを記述します。
NSString *fileBundlePath = [[NSBundle mainBundle] pathForResource:@"TextFile1" ofType:@"txt"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileDocumentDirectorySavePath = [documentsDirectory stringByAppendingPathComponent:@"TextFile1.txt"];
NSFileManager *fm = [NSFileManager defaultManager];
if (![fm fileExistsAtPath:fileDocumentDirectorySavePath])
[fm copyItemAtPath:fileBundlePath toPath:fileDocumentDirectorySavePath error:nil];
これにより、TextFile1.txt がアプリの Documents フォルダーにコピーされ、次のコードを使用して必要なときにいつでも読み取ることができます。
// You can get the fileDocumentDirectorySavePath same way as in the above code
NSString *stringToDisplay = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:fileDocumentDirectorySavePath] encoding:NSUTF8StringEncoding];
NSLog(@"String : %@", stringToDisplay);
これは、作業する必要があるテキスト ファイルの数に関係なく行うことができます。