문제

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