nsoperation

Why does an autoreleased NSTask block the runloop on an NSOperation thread indefinitely?

I've run into an while trying to launch an NSTask from inside an NSOperation. Here's a very simple app I've put together to showcase the problem. When you click the button, an NSOperation is queued. It sets up an NSRunLoop, and calls a method which invokes an NSTask. The task is really simple- it just launches /bin/sleep for two seconds...

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

NSOperationQueue queue waitUntilAllOperationsAreFinished hangs

I have an iphone app where on the loading of a view controller, I want to call a web service , get and parse XML all on the background thread. Then update the ui after the thread is done, then fire off another thread to do a secondard operation in another background thread. Sort of like chaining threading calls: UI Thread -> Create BG...

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

UITableView and NSOperation Logic Problem

Hello everyone, My project is a Thumbnail image gallery. I implemented it using a UITableView which has custom cells. In each cell there's 4 UIButtons which has the images. And the images are downloaded from the internet using their URLs. The way I'm assigning the images to the buttons is using Jasarien's method described in this post....

Playing multimedia content in sequence

Hi I have an NSArray containing many 'multimedia action' as I like to call them, objects that encapsulate some multimedia content like movies and photos. I'd like to 'play' them in sequence waiting each one finished before calling the other. What is the best way to manage the duration of each operation before calling the next one? (for ...

NSURLConnection in NSOperation

Hi I am writing a code that reads data from a http connection and stores in a byte array. I have written my own NSOperation class. Reference of the code is Concurrent Operations Demystified My HttpWorker class declaration is like @interface HttpWorker : NSOperation{ NSString *param; double requestCode; BOOL isLive; l...

Why does NSOperation disable automatic key-value observing?

When working with a custom NSOperation subclass I noticed that the automatic key-value observing is disabled by the [NSOperation automaticallyNotifiesObserversForKey] class method (which returns NO at least for some key paths). Because of that the code inside of NSOperation subclasses is littered by manual calls to willChangeValueForKey:...

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

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

Why does NSOperationQueue on iPhone OS 3.1 hold on to long-cancelled (and released) operations?

I have an app that uses NSOperations to manage service calls to a web API (the calls are based on CURLOperation in Jon Wight's touchcode). There is a certain call that downloads map locations when the center of a map view changes significantly; since these can stack up so quickly, if you move the map around, I try to aggressively cancel...

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

How can I make my app more responsive?

Background This is the same background as my previous question, except the Outline view doesn't have a fetch predicate. I've got an NSOutlineView that shows TrainingGroup entities. The NSOutlineView is bound to an NSTreeController In the NSTreeController, I've got "Preserve Selection" ticked and "Select inserted objects" unticked. Ea...

Best practice to send a lot of data in background on iOS4 device?

I have an app that needs to send date (using POST) to a server. This function has to be on one of the NavigationController sub-controllers and user should be able to navigate away from this controller and/of close the app (only iPhone4/iOS4 will be supported). Should I use threads/NSOperations or/and send data using existing asynchronous...

NSOperation synchronization problem

Hi All, I am struggling to find a way to synchronize operation on IPhone app. I have three main NSOperation. NSInvocationOperation *showSpinner = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(spinnerOn:) object:YES]; NSInvocationOperation *reloadDatasource = [[NSInvocationOperation alloc] initWithTarget:...

Why is my app crashing when I modify a Core Data relationship in an NSOperation subclass?

Background I've got the following tree of objects: Name Project Users nil John nil Documents nil Acme Project Acme Project <--- User selects a project Proposal.doc Acme Project ...