Cancel content editing input request

245 views Asked by At

In my app when you download contentEditingInput, a user can selected a new asset, so I've tried to kill the previous request before starting a new one. Unfortunately cancelContentEditingInputRequest: doesn't work and I still get progress and the completion block is fired when downloading is done. self.asset and self.requestId have expected values. Problem is present when downloading an asset from the iCloud. Did I use API the wrong way?

if(self.requestId) {
    [self.asset cancelContentEditingInputRequest:self.requestId];
}

PHContentEditingInputRequestOptions *options = [PHContentEditingInputRequestOptions new];
options.networkAccessAllowed = YES;
options.progressHandler = ^(double progress, BOOL *stop) {
    // update UI
};

self.asset = newAsset;
self.requestId = [self.asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
    self.requestId = 0;

    // handle content editing input
}];
1

There are 1 answers

0
Tomasz Bąk On BEST ANSWER

I was right about me being wrong. I have used API the wrong way. cancelContentEditingInputRequest: is used to cancel preparing a contentEditingInput from an asset on the device. To cancel the download from the iCloud one should use:

options.progressHandler = ^(double progress, BOOL *stop) {
   *stop = YES;
};

It is a different topic, if the API is logical...