Question

The method -writeData: of NSFileHandle class returns nothing. Is there any way for us to determine whether the operation is successful or not? Or I should use other way to save my data?

No correct solution

OTHER TIPS

According to writeData method Reference, this method raises an exception if the file descriptor is closed or is not valid, if the receiver represents an unconnected pipe or socket endpoint, if no free space is left on the file system, or if any other writing error occurs.

You can write any standard cocoa object to a file pretty simple. This returns a BOOL value if it is sucessful or not

BOOL result = [YOUR_OBJECT writeToFile:@"absolute/file/path" atomically:YES]];

if (result)
    NSLog(@"All went well");
else
    NSLog(@"File was not saved");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top