Is a GCD dispatch queue enough to confine a Core Data context to a single thread Concern One big advantage of GCD dispatch queues is that it manages and makes use of multiple threads to process its FIFO tasks as needed. Each task gets executed by one thread. However, the it “may” be a different thread that processes the next task. So – if I understand this right – tasks […]

thread confinement Thread confinement is the practice of ensuring that data is only accessible from one thread. Such data is called thread-local as it is local, or specific, to a single thread. For example, declaring local variables is a form of thread confinement because each thread has its own local stack. The local variables you declare, […]

Core Data Stack #2 – multiple contexts and resolving conflicts Multiple Contexts manipulating the Database source download Let’s see what happens when we have 2 contexts making changes to the database. First let’s add in an extra NSManagedObjectContext called privateQueueContext2. Implement the custom set method and create our context to execute tasks on a queue.

Then synthesize it and create the custom […]

Core Data Stack #2 – 1 context, background task Updated Demo 5/5/2016 demo 10/26/2015 Have the context process in the background First step is to add a private queue context where it will save a lot of data into the database. add a NSManagedObjectContext privateQueueContext object, synthesize it custom set method where we create the context with a queue queue up tasks […]

Core Data Stack #1 – everything on main queue Everything on Main Queue Create a iOS project and check “using Core Data”. This is how it works: At the most basic level we have a CoreDataStack class. In its implementation file, we first have:

NSManagedObjectModel – Managed Object Model We start with the managed object model. Essentially, it is the schema of […]

Using copy on NSString (mutable and nonmutable) Copy should be used for NSString. If it’s a Mutable NSString (NSMutableString), then it gets copied. If it’s not (NSString), then it just gets retained. Exactly the semantics that you want in an app (let the type do what’s best).

basic inheritance

If the public method is NOT over-ridden, your class extends the hierarchy, then call the public method, you’ll use the public method declared FARTHEST from you Say you have a Base class with a public method called “publicMethod”

Then, you have a Child1 class that derives from Base class. It does not over-ride publicMethod […]

Core Data Part 5 – deleting

Core Data part 4 – rollback

After you get an object and change its attributes, IF YOU DO NOT saveContext, you can rollback the data to its original value. For example, say we get the first indexed Person object. You change the first name to Ricky. If you use [coreDataStack saveContext], that means the change is permanent in the database and […]