views:

39

answers:

0

I have a class called DataRequest, which handles downloading data from a web service via NSURLRequest, parsing the results and stuffing data into a NSManagedObject, and saving it. It contains the fowlling:

@property (nonatomic, retain) id DataControllerProtocol dataController;

I also have a class called DataController, which encapsulates the following:

NSManagedObjectModel *managedObjectModel;  
NSManagedObjectContext *managedObjectContext;       
NSPersistentStoreCoordinator *persistentStoreCoordinator;  

I also have a DataControllerProtocol that has the following:

@property (nonatomic, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;

Each DataRequest class gets assigned the same DataController class. Then, each time the each time a user clicks a row in a table, I am firing off a new DataRequest to download data, save it, and display it.

In my ViewController class, I have a NSFetchResultsController that handles the fetching. The NSFetchResultsController has the correct data the first time a row is touched after the data is downloaded and saved. After the second row is clicked, data downloaded and saved, some of the data of the first row's NSManagedObject is lost!

Is this a threading issue with Core Data? I'm at a loss for what the problem is.