nsoperationqueue

NSThread vs. NSOperationQueue vs. ??? on the iPhone

Currently I'm using NSThread to cache images in another thread. [NSThread detachNewThreadSelector:@selector(cacheImage:) toTarget:self withObject:image]; Alternatively: [self performSelectorInBackground:@selector(cacheImage:) withObject:image]; Alternatively, I can use an NSOperationQueue NSInvocationOperation *invOperation = [[N...

Extra retain needed on NSOperation

I'm developing an iPad app. It uses an NSOperation to download something in the background, processed by an NSOperationQueue. I'm finding that, unless I add a retain to the NSOperation, I hit a crash after the operation's action is performed. NSOperationQueue's addOperation says it retains the NSOperation, and the NSOperation itself r...

NSOperationQueue seems to hang on completion for a few seconds

I have a custom view controller that implements the from UITableViewDataSource and UITableViewDelegate protocols. When I load data for my table (in my viewDidLoad method), I create a NSOperationQueue and a NSInvocationOperation and add it to the queue. I throw up an activity indicator, and viewDidLoad exits. The method used for the op...

Cancelling NSOperationQueue from within NSOperation

I have some iPhone SDK 4.0 code which initializes an NSOperationQueue and then adds three classes (ClassA, ClassB, and ClassC) to run one after the other. ClassA, ClassB, and ClassC are all sub-classes of NSOperation. The relevant code is included below. ClassA *classA = [[ClassA alloc] init]; ClassB *classB = [[ClassB alloc] init]; Cl...

NSOperation KVO problem

Hi all, I'm using following function to get my application notified after the operation in nsoperationqueue has finished, so that I can schedule the task that's dependent upon the result of the operation. I'm using: - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object ch...

How to get notified when all the NSOperation in NSOperationQueue get completed?

I tried something like _queue = [[NSOperationQueue alloc] init]; [_queue addObserver:self forKeyPath:@"operations" options:NSKeyValueObservingOptionNew context:NULL]; for(NSString *url in [_filesToDownload allKeys]) { UrlDownloaderOperation * operation = [UrlDownloaderOperation urlDownloaderWithUrlString:url folderName:folder fi...

NSOperationQueue dispatching threads slowly?!

I'm writing my first multithreaded iPhone apps using NSOperationQueue because I've heard it's loads better and potentially faster than managing my own thread dispatching. I'm calculating the outcome of a Game of Life board by splitting the board into seperate pieces and having seperate threads calculate each board and then splicing them...

NSOperationQueue and ASIHTTPRequest

I'm writing test cases for a wrapper class written around ASIHTTPRequest. For reasons I can't determine, my test cases complete with failure before the ASIHTTPRequest finishes. Here's how the program flow works. Start in my test case. Init my http engine object, instruct it to create a new list Create the new ASIHTTPRequest object and...

How can I make sure NSOperations execute in a failsafe way?

What I Want I've got an NSOperationQueue in my application and it's critical that all operations get processed before the application quits. I've got the following code on quit to make sure the NSOperationQueue is empty before quitting: if ([NSThread isMainThread]) { while ([[operationQueue operations] count] > 0) { [[NSRun...

Adding NSOperation to NSOperationQueue that starts asynchronous ASIHTTPRequest

So I'm trying to do all my REST calls that download data on the background thread so that the UI stays responsive. I have a viewcontroller that contains a NSOperationQueue. I create an instance of my importer class that is a subclass of NSOperation. Inside the main() method of my importer, I am setting up a ASIHTTPDataRequest. I create ...

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

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,...

Why is my application terminating in the middle of unit tests?

The Problem I run my unit tests. At one point, I wait using: [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; for an NSOperationQueue to be empty. When my app reaches this line, it terminates immediately. It's run this exact same line with other tests. All tests were working perfectly recently. It al...

Issues with NSOperationQueue and dealloc being called and crashing App

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 fin...

Pause NSOperation

I have NSOperationQueue with some NSOperations in it (NSInvocationOperations, in particular). This operations do some calculations and change states of UI elements accordingly (of course, via performSelectorOnMainThread:...), often with use of animations. My UI has UINavigationViewController and some buttons for navigation to another vi...

Remove all requests from ASINetWorkQueue

Hi there. Does someone know a way to remove requests from an ASINetworkQueue in a persistent way? The reset function doesn't seem to do the job. What I'm trying to do is the following - (void)fillAndRunQueue:(ASINetworkQueue*)queue requests:(NSArray*)requests { for (ASIHTTPRequest* request in requests) { if ([reques...

iPhone / iOS popViewControllerAnimated Does not refresh screen

Greetings, I have a strange issue when calling .navigationController popViewControllerAnimated:YES from an NSOperation where the screen does not properly update and leaves the popped view visible but apparently deallocated. Details: I have a list view that accesses a local sqlite database. When tapping on a record, it displays that r...

What is the recommended max number of nsoperationqueues

I have a gallery app that i am writing and need to download up to 30 images to the phone for offline viewing. Downloading isn't a problem but I am wondering what the recommend number of queues that I should create for downloading the images. ...

NSOperation queue problems

hello i have 2 methods which are accessing on the same method redrawView those are moveThePlayerWithDeltasAndQueue and movethePlayerAroundYAxisAndQueue i would like to use an operation queue like in the commented code but i have no fortune to run it well what is the right way for build the queue and let work them right ? http://paste...

NSOperation(s) leaks only on iOS 3 device

I have some NSOperations subclasses that handle CoreData imports. I believe i've ticked most of the non-main thread issues I create my own autorelease pool in the main method I create a NSManagedObjectContext for each operation These operations are loaded into a NSOperationQueue, with the maximum number of concurrent operations set 1...

NSURLConnection Problem with NSOperationqueu

Hi I am trying to create a NSOperaion Queue to download a bunch of PDF files. But it doesnt work. The delegate methods dont get called for NSURLConnection since i put them in NSOperation queue.... any alternatives or solution??? - (void) loadData { NSOperationQueue *queue = [NSOperationQueue new]; NSInvocationOperation *operation; fo...