nsoperationqueue

Initial coredata save freezes app

China☆狼群 提交于 2019-12-24 08:09:36
问题 I have an iOS application using coredata with three different models. The data is pulled from a json feed from a server then saved. Each API call is run on a thread using NSOperationQueue so they never execute at the same time. On the final call I save to the largest model being stored it is after the save happens that the application hangs. The UI becomes unresponsive and the debugger gives no errors. This only happens on the first load of the app, afterwards every subsequent load runs

Issues with NSOperationQueue and dealloc being called and crashing App

家住魔仙堡 提交于 2019-12-24 07:03:27
问题 I've created an NSOperation in the queue like so: ImageLoadingOperation *operation = [[ImageLoadingOperation alloc] initWithImageURL:url target:self action:@selector(didFinishLoadingImageWithResult:)]; [operationQueue addOperation:operation]; [operation release]; And this works fine but if the view gets popped before the operation finishes the App crashes with "EXC_BAD_ACCESS" I've tried to cancel the the operation Queue by calling cancelAllOperations but as its already in process it doesn't

How do I wait until an NSOperationQueue has finished in a Unit Test?

南笙酒味 提交于 2019-12-24 06:31:38
问题 The Problem I have an NSOperationQueue called logEntryGeneratorQueue I want to wait until all operations on the queue have completed If I use: [logEntryGeneratorQueue waitUntilAllOperationsAreFinished]; it works fine if the thread adding to the queue is in the background itself. However, if I'm running this code via a unit test, it'll be running on the main thread. So I came up with this "solution", which I really don't like: if ([NSThread isMainThread]) { while ([[logEntryGeneratorQueue

Two simultaneous background tasks using NSOperationQueue

冷暖自知 提交于 2019-12-24 04:03:09
问题 I have two tasks that i need to perform in background simultaneously with different thread priorities: continuously gather and process gyro motion data (high priority) gyroQueue = [[NSOperationQueue alloc] init]; [self.motionManager startDeviceMotionUpdatesToQueue:gyroQueue withHandler:^(CMDeviceMotion *motion, NSError *error){ [self processMotion:motion withError:error]; }]; Sometimes process images without interfering with motion updates (convert, crop, sesize, etc = 1-2sec) (very low

performSelector in NSOperation subclass

[亡魂溺海] 提交于 2019-12-24 00:52:35
问题 I couldn't find an answer anywhere else on the net so any help would be appreciated. I am tying to create a system whereby I can retrieve the results of an NSOperation task, which I understand cannot be done by concrete subclasses such as NSInvocation. I have an NSOperation subclass ( TheEngine ) which is abstract by convention and must be extended to implement the function -main , to include the body of code to execute. TheEngine contains the following initialisation function whose job is

Building up UIViews on background thread

£可爱£侵袭症+ 提交于 2019-12-23 12:58:14
问题 I'm aware that the UI should only be updated on the main thread, but is it possible to create and add subviews on a separate thread, as long as they are not added to the visible view? Will it cause memory and performance issues? Here's some example code. NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [queue addOperationWithBlock:^{ // do some fancy calculations, building views UIView *aView = .. for (int i, i<1000, i++) { UIView *subView = … [aView addSubview:subView]; } // Update

Swift: Retain cycle with NSOperation

假如想象 提交于 2019-12-23 12:43:10
问题 In my app I use an image loader class to load images from the web for a collection view. The class keeps track of the download operations and cancels them when the cells for the images are no longer visible in the collection view. This implementation is based on the raywenderlich tutorial for NSOperation: http://www.raywenderlich.com/76341/use-nsoperation-nsoperationqueue-swift. I use NSOperation for downloading an image from the web. I noticed with Instruments that none of the NSoperations

Why is my NSOperationQueue not behaving correctly in iOS 4.0?

独自空忆成欢 提交于 2019-12-23 04:51:17
问题 I have used NSOperationQueue in my iPhone app before in iPhone OS 3.0, but now in iOS 4.0 the code is not working properly. It runs properly only once and on all subsequent calls, it doesnt work. Have there been changes in NSOperationQueue in iOS 4.0? The relevant code is as follows: - (void) starteffectFunction { NSOperationQueue *queue = [NSOperationQueue new]; NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(starteffectProcessing)

NSOperationQueue: a sequence of NSOperation's with dependencies VS (maxConcurrentOperationCount == 1)?

蓝咒 提交于 2019-12-23 02:46:26
问题 For example I have 3 objects: NSOperation *op1 = ...; NSOperation *op2 = ...; NSOperation *op3 = ...; [op3 addDependency:op2]; [op2 addDependency:op1]; NSOperationQueue *queue = ...; queue.maxConcurrentOperationCount = 1; [queue addOperations:@[op1, op2, op3] waitUntilFinished:NO]; I could simply add all the operations in correct order. But for example if op2 is cancelled then I should also cancel op3 and I can't fully clear a queue in this case. My questions: 1)Is it safe to combine such

Can't cancel executing operations in OperationQueue swift

不羁的心 提交于 2019-12-22 06:31:23
问题 Im doing some lengthy calculations to create chart data on a background thread i was originally use GCD, but every time a user filters the chart data by hitting a button, the chart data needs to be recalculated, if the user clicks the chart data filtering buttons very quickly (power user) then the chart loops through each drawing as each GCD dispatch async finishes I realize that I can't cancel threads with GCD so I've moved to trying to implement an OperationQueue I call cancelAllOperations(