Reputation: 517
-(void)WriteToFile:(NSString*)fileName andString:(NSString*)array{
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.txt",fileName]];
NSData *serializedData = [NSKeyedArchiver archivedDataWithRootObject:array];
[serializedData writeToFile:filePath atomically:YES];
}
I have a big NSString
that I want to write to a text file. How do I check if it is already done?
Upvotes: 0
Views: 568
Reputation: 64002
-[NSData writeToFile:atomically:]
doesn't return until the write has either completed or failed. Until control passes back to your code, the operation is still running.
Check the returned BOOL
to see if the write has succeeded.
Upvotes: 1