Core Data on multiple threads

I have a Core data managedObjectContext on the main thread, then I created another managedObjectContext on the background thread. If there is a change on the background thread I just call the ManagedObjectDidSave notification. My question is if I made a change on the mainthread, I also need to tell the managedObjectContext on the background thread right?

I have user a user data class which gets and sets userdata on both main and background thread. I should pass the managedobject of the thread I am calling this userdata class from, right?

Thanks for your help.

-------------Problems Reply------------

My question is if I made a change on the mainthread, I also need to tell the managedObjectContext on the background thread right?

If you want to make the background thread aware of any changes on the main thread you must register it for notifications. Usually, however, the background thread has some special task to process and just ignores the main thread until it is done.

I have a user data class which gets and sets userdata on both the main and background threads. I should pass the managedobject of the thread I am calling this userdata class from, right?

Yes, keep the managedObject on the same thread until the context have merged.

Category:ios Views:0 Time:2011-08-23
Tags: ios core data

Related post

  • correct use of core data for multiple access to the data - iphone/ipad 2010-03-09

    I got a question ;) Actually I want to use core-data in different threads. I have two UIviews that display data from the same table in the database. If a remove an entry in the first view I'm supposed save and then ask the PersistentStoreCoordinator

  • Implementing a buffer to write data from multiple threads? 2011-01-12

    My program uses an iterator to traverse through a map, and spawns off a number of worker threads to process the points from the read iterator, which is all good. Now, I'd like to write the output for each point, and for that I'm using a memory buffer

  • Core Data with Multiple Background Threads 2012-03-02

    I have an iphone/ipad app using Core Data. Data is provided via various web service calls. I use a polling mechanism to determine when each of the service calls are to be made, independently from one another, in order to keep information up to date.

  • Is it practically safe to write static data from multiple threads 2009-02-26

    I have some status data that I want to cache from a database. Any of several threads may modify the status data. After the data is modified it will be written to the database. The database writes will always be done in series by the underlying databa

  • How to gather data from multiple threads in python? 2011-04-13

    I'm wanting to use multiple threads in Python to calculate pixel values for an image, to be constructed at the end, though I'm having trouble figuring out how to get the result of the thread back and collected. Here's the setup: A Queue.Queue() objec

  • Core data saving in thread 2011-11-30

    I'm developing a client server application in iPad. I need to save quite a number of data the server sends me. it sends me a long string, and i have to break it up into small records and save it in core data. it sends me a total of probably 20 messag

  • Core Data: Merging multiple Managed Object Contexts and deleting objects 2010-03-15

    I have an iPhone project where I have a series of Managed Objects in a Managed Object Context within the main application thread. On a separate thread, I import new objects from a webserver into a second Managed Object Context. If the import goes ok

  • Saving core data in a thread, how to ensure its done writing before quitting? 2010-04-07

    So I'm saving small images to core data which take a really short amount of time to save, like .2 seconds but I'm doing it while the user is flipping through a scroll view so in order to improve responsiveness I'm moving the saving to a thread. This

  • How to log data from multiple threads? 2010-10-05

    There are huge numbers of threads running in parallel continuously (let's assume this continuous part)). All the threads want to log some application data, basically a set of values. What would be the best approach to log this data? single/multiple f

  • Is it wise to access read-only data from multiple threads simultaneously? 2011-04-13

    I have an application that I'm trying to make multithreaded. Each thread will access a large chunk of read-only data. Is is okay if multiple threads access the data simultaneously? I know that if the data were not read-only, I would need to use mutex

  • Saving Core Data From Multiple TableVIews 2011-06-01

    I have an app that has multiple tableviews and I want to use Core Data to capture all the data. I have two entities - freezers and items. In the first tableview I add a freezer and it saves correctly. I quit the app, re-open, and it is there. I click

  • processing large data using multiple threads of same code in linux C 2011-06-16

    can multiple threads of same function be created to process large arrays in small blocks? i am trying to do it in Linux C, assume i have read() it is reading data from serial into array, when array is full it is passed for processing to stable(), mea

  • Emptying a Core Data NSSet (multiple relationships) 2011-11-09

    If I need to programmatically empty a NSSet automatically created by Core Data (multiple relationships), what should I do ? Something like this ? [self willChangeValueForKey:@"MyRelationship"]; [[self MyRelationship] release]; [self MyRelationship] =

  • Qt: How to synchronize access to data from multiple threads in model/view setup? 2011-12-20

    How to synchronize access to data accessed from multiple threads in Qt model/view setup? I'm using QTableView with a Model class. Model extends QAbstractTableModel and has an instance of a custom class Net that holds actual data to be displayed to QT

  • Issues with core data and background thread 2011-12-30

    Happy New year. Iam working with a app where data is saved by using core data. The app contains a calendar module and the user is allowed to skip back/forth between dates by two buttons(nextDay, previousDay). Each day contains som information which I

  • Core Data with multiple viewControllers 2012-01-16

    I'm having a lot of difficulty getting core data to work in my application. I'm perfectly comfortable with core data in a table view controller and even with core data in a single view application. I'm unable however to get my program to function pro

  • iPhone Core Data saving multiple items at once random behavior? 2009-12-10

    I have an application that reads an rss feed, parses the xml and adds it to my database using Core Data (this is so the user can see the feed even if no internet connection is available) this all works fine. The way I am doing the parsing is: on the

  • Core Data: Create multiple managed objects, but only save some? 2010-08-26

    I'm trying to write a favorites system for my app. I've already converted my model to a managed object. So imagine the user is presented a screen with a list of such objects. They can choose to save some to their favorites, which will persist them in

  • Core Data Query Multiple Columns with Single Search String 2011-02-18

    I have a simple Core Data model with two string attributes (size and category). Given a search string like 'small widget' is it possible to return records that match all the query words to at least one attribute (i.e. all records with 'small' size an

Copyright (C), All Rights Reserved.

processed in 0.205 (s). 11 q(s)