アプリのドキュメント フォルダーにある tt ファイルに文字列を書き込もうとしています。文字列を書き込むことはできますが、別の文字列をファイルに書き込むと、他の文字列が上書きされます。文字列の間に空白行を入れて、多くの場合、この形式のテキストファイルにさらに文字列を書き込むことは可能ですか?
弦
弦
ストリン
…</p>
このコードを使用して文字列をテキスト ファイルに書き込みます。1 つの文字列では機能しますが、複数の文字列では機能しません。
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//make a file name to write the data to using the documents directory:
NSString *fileName = [NSString stringWithFormat:@"%@/Barcodedata.txt",
documentsDirectory];
//create content - four lines of text
NSString *content = [NSString stringWithFormat:@"%@",sym.data];
//save content to the documents directory
[content writeToFile:fileName
atomically:NO
encoding:NSStringEncodingConversionAllowLossy
error:nil];