
I am using the PDFKit Framework in my cocoa application for PDFViewer. When I try to delete one of the pages from the PDFDocument, the application freezes in the line of code
[[self pdfDocument]  removePageAtIndex:0]; // can see this Problem only in Mac OS X 10.11
This works great when I run the application on Mac OS X 10.10
I have read all the related Apple documents, but I have not received any solution yet.
Here is the back trace:
* thread 
    frame 
    frame 
    frame 
    frame 
  * frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
    frame 
here is the method in which i use the removePageAtIndex PDFDocument method
-(NSError *)removePageOpImpl:(NRMPDFOperation *)op
{
    NSLog(@"\n Inside removePageOpImpl Method ...");
    NSError* error = [self loadDocument];
    if( !error )
    {
        NSUInteger index = [self pageIndexForId:[op pageId]];
        NSLog(@"Page count: %ld", [self pageCount]);
        if( index < [self pageCount] )
        {
            NSLog(@"PDF Document:-- %@", [self pdfDocument]);
            NSLog(@"Index is: %ld", index);
            @try {
                [(PDFDocument *)[self pdfDocument]  removePageAtIndex:index];
                NSLog(@"Page count after delete: %ld", [self pageCount]);
            }
            @catch (NSException *exception) {
                NSLog(@"Exception: %@", exception);
            }
            @finally {
                NSLog(@"Finally called");
                [[self mutablePageIdList] removeObjectAtIndex:index];
                [self updatePageLabelsFromIndex:index];
                [self updateChangeCount:NSChangeDone];
                self.contentsChanged = YES;
            }
        }
        else
        {
            
        }
    }
    return error;
}
Can someone please suggest me what might be the problem ... also added screenshots of the queues that blocked the user interface
I tried applying dispatch_async in the main queue to delete PDFDocument page operations as shown below
- (NSError *)removePageOpImpl:(NRMPDFOperation *)op
{
    NSError* error = [self loadDocument];
    if( !error )
    {
        NSUInteger index = [self pageIndexForId:[op pageId]];
        if( index < [self pageCount] )
        {
                dispatch_async(dispatch_get_main_queue(), ^{
                        [[self pdfDocument] removePageAtIndex:index];
                        [[self mutablePageIdList] removeObjectAtIndex:index];
                        [self updatePageLabelsFromIndex:index];
                        [self updateChangeCount:NSChangeDone];
                        self.contentsChanged = YES;
                        });
        }
        else
        {
            
        }
    }
    return error;
}
, . , removePageOpImpl. removePageOpImpl, . , removePageOpImpl. , , .
,