nsoperationqueue

PDFKit background search

喜你入骨 提交于 2020-06-12 15:52:08
问题 I'm trying to run a search on a background thread using new iOS PDFKit framework. 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) } The problem is that none of the PDFDocumentDelegate's methods isn't called and if I

Is there something like NSOperationQueue from ObjectiveC in Python?

99封情书 提交于 2020-05-18 20:54:51
问题 I'm looking into concurrency options for Python. Since I'm an iOS/macOS developer, I'd find it very useful if there was something like NSOperationQueue in python. Basically, it's a queue to which you can add operations (every operation is Operation-derived class with run method to implement) which are executed either serially, or in parallel or ideally various dependencies can be set on operations (ie that some operation depends on others being executed before it can start). 回答1: have you

iOS之 CoreMotion 框架

二次信任 提交于 2020-04-07 06:01:20
在项目中经常会使用到重力加速度,陀螺仪,最近在一个项目中使用到了CoreMotion 框架,需求是:上下摇摆手机控制智能椅子的角度调节,该项目是使用蓝牙4.0进行通讯的,在iOS 内已经封装好了CoreBluetooth 框架,不过需要iPHone4s 以上的手机,和iPad min 以上的平板电脑才有蓝牙4.0. 今天在这里先记录一下CoreMotion 框架的使用. 主要的类:CMMotionManager , NSOperationQueue. 下面是一个被我封装过的一个类。 项目需要导入CoreMotion.Framework 在.h 文件需要#import <CoreMotion/CoreMotion.h> .h文件代码: #import <Foundation/Foundation.h> #import <CoreMotion/CoreMotion.h> typedef enum _MotionDirection {UNKNOWDIRECTION=0,UP,DOWN}MotionDirection; @interface iCtrlCMManager : NSObject @property (nonatomic,retain) CMMotionManager * ictrlCMManager; @property (nonatomic,assign)

iOS Download & Parsing Large JSON responses is causing CFData (store) leaks

非 Y 不嫁゛ 提交于 2020-01-21 10:20:33
问题 The first time a user opens my app I need to download lots of data. I get all of this data from the server in JSON form. Depending on the user, these JSON files can be anywhere from 10kb - 30mb each, and there are 10+ of them. I have no problems doing this when the JSONs have no more than 500 or so records, but like I said some have 10,000+ records and can be up to 30mb in size. When downloading the larger JSONs, my app allocs a ton of memory, until I eventually get memory warnings and the

NSOperation - Forcing an operation to wait others dynamically

回眸只為那壹抹淺笑 提交于 2020-01-19 19:02:18
问题 I am trying to implement an operation queue and I have the following scenario: NSOperation A NSOperation B NSOperation C NSOperation D NSOperationQueue queue I start adding A to queue . During the execution of A I need to get some data from B and I can't continue with A until B returns what I need. The same situation will occur for B depending on C and for C depending on D . To manage this, at each NSOperation I have this code: NSOperation *operation; //This can be A, B, C, D or any other

How to stop DispatchGroup or OperationQueue waiting?

依然范特西╮ 提交于 2020-01-14 03:32:24
问题 DispatchGroup and OperationQueue have methods wait() and waitUntilAllOperationsAreFinished() which wait for all operations in respective queues to complete. But even when I call cancelAllOperations it just changes the flag isCancelled in every running operation and stop the queue from executing new operations. But it still waits for the operations to complete. Therefore running the operations must be stopped from the inside. But it is possible only if operation is incremental or has an inner

Managing Multiple Operations in Single NSOperationQueue iOS like Pause/Resume single Operation

丶灬走出姿态 提交于 2020-01-13 07:20:13
问题 In my code I want to handle operations individually in a queue and be able to pause and resume the operations operation in the queue. How can I implement that ? Let me explain my question in brief, I have used below code for creating operation by subclass NSOperation and added this operation to NSOperationQueue. @interface MyLengthyOperation: NSOperation @end @implementation MyLengthyOperation - (void)main { // a lengthy operation @autoreleasepool { for (int i = 0 ; i < 10000 ; i++) { // is

Managing Multiple Operations in Single NSOperationQueue iOS like Pause/Resume single Operation

匆匆过客 提交于 2020-01-13 07:20:09
问题 In my code I want to handle operations individually in a queue and be able to pause and resume the operations operation in the queue. How can I implement that ? Let me explain my question in brief, I have used below code for creating operation by subclass NSOperation and added this operation to NSOperationQueue. @interface MyLengthyOperation: NSOperation @end @implementation MyLengthyOperation - (void)main { // a lengthy operation @autoreleasepool { for (int i = 0 ; i < 10000 ; i++) { // is

iOS之[多线程:NSOperation]

你离开我真会死。 提交于 2020-01-07 06:16:06
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1. NSOperation :fa-exclamation-triangle: 以下是你需要考虑使用 NSOperation 的一些理由: 1.当你需要取消线程任务时,GCD 无法提供取消任务的操作。而 NSOperation 提供了取消任务的操作; 2.当你需要更细的粒度地观察任务改变了状态时,由于 NSOperation 是一个对象,比较 GCD 使用的 block 而言,通过对 NSOperation 对象进行键值观察(KVO)能很容易观察到任务的状态改变; 3.当你需要重用线程任务时,NSOperation 作为一个普通的 Objective-C 对象,可以存储任何信息。对象就是为重用而设计的,这时,NSOperation 比 GCD 使用的 block 要更方便。 1.1 NSOperation简介 实际开发中使用的是NSOperation的两个子类 - NSInvocationOperation - NSBlockOperation :使用block形式组织代码,相对方便 1.2 线程的创建执行过程 异步:创建NSOperation -> 创建NSOperationQueue队列 -> 将NSOperation添加到Queue中 同步:创建NSOperation -> 调用start方法 1.3

Delegate method not being called

本小妞迷上赌 提交于 2020-01-05 05:08:27
问题 I am making an OpenSource (github) helper class for downloading images asynchronously (I had major trouble with). However, I have delegate methods set up to alert the delegate that a image has finished downloading. The problem is that the delegate method is not getting called. I am setting the delegate and everything, but I don't have a clue why the problem is occurring. Please take a look at my code! I have only posted the relevant code. MKAsyncImageDownloader.h @protocol