views:

30

answers:

1

In iPhone, how do you determine if a file couldn't be written to the documents area because of an out of space error?

A: 

fwrite returns the number of items written, so you can check if it's consistent to know if there's any errors:

if (fwrite(data, sizeof(Something), 1234, fp) != 1234) {
  // handle error.
}

This is the only documented way to check if a fwrite failure (including out-of-space error) happens.

KennyTM
Should probably also do a fflush() and check the status of that.
David Gelhar