nsoperation

NSoperation and key value observing

Hello guys! I am creating a MyOperation object (inherited from NSOperation) and add to a NSOperationQueue. Then I am doing KVO on MyOperation. I am using this method - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; to get a value from MyOperation if it is fi...

NSOperation and UIKit problem

Hello guys! I am doing my download with an object which was inherited from NSOperation. I have read the documentation and when my operation finished I must call the [self.delegate performSelectorOnMainThread:@selector(operationDidFinish:) withObject:self waitUntilDone:YES]; method. It needs to be called on the main thread, because th...

iPhone: Memory leak when using NSOperationQueue...

Hi, I'm sitting here for at least half an hour to find a memory leak in my code. I just replaced an synchronous call to a (touch) method with an asynchronous one using NSOperationQueue. The Leak Inspector reports a memory leak after I did the change to the code. What's wrong with the version using NSOperationQueue? Version without a M...

NSOperation unable to load data on the TableView

I have a problem in NSOperation. I tried many ways but it would run behind the screen, but will not make it appear on the my table view. Can anyone help me out with this. I am new to NSOperation. Recents.h #import <UIKit/UIKit.h> #import "FlickrFetcher.h" @interface Recents : UITableViewController { FlickrFetcher *fetcher; NSString ...

Running out of memory with UIImage creation on an offscreen Bitmap Context by NSOperation

I have an app with multiple UIView subclasses that acts as pages for a UIScrollView. UIViews are moved back and forth to provide a seamless experience to the user. Since the content of the views is rather slow to draw, it's rendered on a single shared CGBitmapContext guarded by locks by NSOperation subclasses - executed one at once in an...

Core Data blocking UI after asynchronous NSURLConnection didLoadResource on iPhone

Each time somebody touches a row inside a UITableView, I'm kicking off a series of asynchronous NSURLConnections, that download data and then parse and save that data into Core Data. The problem is that when I do this, the UI is responsive during the data download, but as soon as the parsing and saving begins, the UI becomes non-respons...

iPhone: NSOperationQueue running operations serially

I have a singleton NSOperationQueue that handles all of my network requests. I'm noticing, however, that when I have one particularly long operation running (this particular operation takes at least 25 seconds), my other operations don't run until it completes. maxConcurrentOperationCount is set to NSOperationQueueDefaultMaxConcurrentOp...

Perform selector on parent NSOperation

I extend NSOperation (call it A) which contains NSOperationQueue for other NSOperations (which is another extended class different from A, call these operations B). When operation A is running (executing B operations) how do i call a specific function/method on operation A when certain event takes place on B operations? For example every...

XML parsing on new thread

Hi all, In my application, I want to fetch new xml data after user scrolls through tableview and pulls the first cell down. As the data is loaded in tableview in chronological order, the updated data will be shown before the first cell. I want to run this process on new thread, so what is the best option : Subclass NSThread and use i...

Difference between performSelectorInBackground and NSOperation Subclass

I have created one testing app for running deep counter loop. I run the loop fuction in background thread using performSelectorInBackground and also NSOperation subclass separately. I am also using performSelectorOnMainThread to notify main thread within backgroundthread method and [NSNotificationCenter defaultCenter] postNotificationN...

NSOperation Causing Crash when Passed to Delegate

For an iPhone app, I'm using a NSOperationQueue to limit access to the SQLite database to one query at a time. I created a subclass of NSOperation and in the main function I have the following: - (void)main { // ... other code here ... if( [_delegate respondsToSelector:@selector(queryCompleted:)] ) { [_delegate ...

nonatomic property in model class when using NSOperationQueue (iPhone)?

I have a custom model class with an NSMutableData ivar that will be accessed by custom NSOperation subclasses (using an NSOperationQueue). I think I can guarantee thread-safe access to the ivar from multiple NSOperations by using dependencies, and I can guarantee that I don't access the ivar from other code (say my main app thread) by ...

NSOutlineView not refreshing when objects added to managed object context from NSOperations

Background Cocoa app using core data Two processes - daemon and a main UI Daemon constantly writing to a data store UI process reads from same data store Columns in NSOutlineView in UI bound to an NSTreeController NSTreeControllers managedObjectContext is bound to Application with key path of delegate.interpretedMOC NSTreeController...

IconDownloader, problem with lazy downloading

My problem is simple to be described but it seems to be hard to solve. The problem is loading icons, with a custom class like IconDownloader.m provided by an official example from Apple, avoiding crashes if I release the view. I've added the IconDownloader class to my app, but it's clear that this approach is good only if the tableview ...

Cocoa & Cocoa Touch. How do I create an NSData object from a plain ole pointer?

I have malloc'd a whole mess of data in an NSOperation instance. I have a pointer: data = malloc(humungous_amounts_of_god_knows_what); uint8_t* data; How do I package this up as an NSData instance and return it to the main thread? I am assuming that after conversion to an NSData instance I can simply call: free(data); Yes? Also, b...

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

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 synchronise two NSManagedObjectContext

Hi everybody, I'm working on an ipad application that use coredata. It download information on a database that is on the web, and record them in coredata. The application is based on a split view. My problem was to make the download and the record of the data in background. Here is how I've done : - I've create an NSOperation, that does ...

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

NSOperation not adding subview to main view

I am running into an strange behavior when using NSOpeation. I am calling a function (-createTagView) that creates an UIButton to then add it to a view. For some reason it's not adding them. If I call the function from outside the NSOperation everything works fine. Any ideas? Thanks. This how I create the NSOperation (within a ViewCont...