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?

没有正确的解决方案

其他提示

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");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top