2011-10-20 12 views

答えて

184

はい。そうなる。

ここには30文字の制限を超えるいくつかの文字があります。

+47

+1、あなたの余分な文字を「文書化」:) – Julian

+17

あなたがアトミックかdoesnのそれを行うかどうかについて問題ありません。どちらの場合でも、ファイルは新しいデータで完全に上書きされます。 –

+0

ああ、私にとっては失敗し、元のファイルはそのままです。 writeToFileはNSErrorを返さないため、どのようにして障害を調査できますか?それは許可の問題かもしれませんが、私は確信が持てません。私のコードは、インストーラのプラグインバンドルとして実行されます。これは、ルート特権を必要とするインストールパッケージのためです。私のコードの実行権限を確認/印刷する方法はわかりません。 –

3

方法writeToFile:atomically:常にatomically: YESまたはNOに関係なく、オーバーライトファイルApple docs(NSDataのは、 "データの保存")から

情報:ファイルが存在するかどうかのチェックについて

The NSData class and its subclasses provide methods to quickly and easily save their contents to disk. To minimize the risk of data loss, these methods provide the option of saving the data atomically. Atomic writes guarantee that the data is either saved in its entirety, or it fails completely. The atomic write begins by writing the data to a temporary file. If this write succeeds, then the method moves the temporary file to its final location.

ない一言。

例えば、具体的には、チェックについて書かれdocsにおける方法copyItemAtPath:toPath:error:(NSFileManager、セクションのディスカッション)について:

If a file with the same name already exists at dstPath, this method stops the copy attempt and returns an appropriate error.

関連する問題