Answer the question
In order to leave comments, you need to log in
How to write data to end of file using NSFileCoordinator while saving UIDocument to iCloud?
Have your own UIDocument
, redefined
writeContents:toURL:forSaveOperation:originalContentsURL:error:
and in it I try to write data to the end of the file using , but it only turns out to overwrite the file, all other options do not work, it gives an error. There is another method[NSFileCoordinator coordinateWritingItemAtURL::::]
coordinateReadingItemAtURL:options:writingItemAtURL:options:error:byAccessor:
but as I understand it, it is for different files, it is not clear how it can be used in my case. There is very little information on this subject. :(
Answer the question
In order to leave comments, you need to log in
Adding to the file is done through the handler, for example like this:
NSString *dir = [pathCache stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.download", [itemToDownload fileName]]];
if(data)
[tmpData appendData:data];
if(![tmpData length])
return;
NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:dir];
[handle seekToEndOfFile];
[handle writeData:tmpData];
[handle closeFile];
[tmpData setLength:0];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question