2017-10-05 20 views
0

新しいiOS PDFKitフレームワークを使用してバックグラウンドスレッドで検索を実行しようとしています。PDFKitバックグラウンド検索

override func main() { 
    if isCancelled { 
     return 
    } 
    pdfDocument = PDFDocument.init(url: book.document.url)! 
    pdfDocument.delegate = self 
    pdfDocument.beginFindString("test", withOptions: [.caseInsensitive, .diacriticInsensitive]) (async) 
    //pdfDocument.findString("test", withOptions: [.caseInsensitive, .diacriticInsensitive]) (sync) 

    } 

問題がPDFDocumentDelegateの方法のいずれもが呼び出されていないされていないことであると私はTIMEプロファイラを使用する場合は何も起こりませんように見えます。 syncオプションは機能しますが、キャンセルすることはできません

アイデア?

答えて

0

デリゲートメソッドは、同期のために正常に動作しますfindString

あなたは通知に頼るべきで非同期beginFindStringの場合:

// Objective - C 
PDFDocumentDidBeginFindNotification 
PDFDocumentDidEndFindNotification 
PDFDocumentDidBeginPageFindNotification 
PDFDocumentDidEndPageFindNotification 
PDFDocumentDidFindMatchNotification 

または

// Swift 
Notification.Name.PDFDocumentDidBeginFind 
Notification.Name.PDFDocumentDidEndFind 
Notification.Name.PDFDocumentDidBeginPageFind 
Notification.Name.PDFDocumentDidEndPageFind 
Notification.Name.PDFDocumentDidFindMatch 
+0

問題が 'FUNCのdocumentDidBeginDocumentFind(_通知、' beginFindString'は、バックグラウンドスレッドで何もしないということです:通知) 'が呼び出されます。メインスレッドではすべて正常に動作します。私の推測では、非同期検索にはスレッドガードがあります。私はデリゲートと通知も試みました。 –

関連する問題