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.
How to determine if a write operation is successful using NSFileHandle?
-
30-06-2022 - |
문제
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?
올바른 솔루션이 없습니다
다른 팁
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");
제휴하지 않습니다 StackOverflow