James Dorfman James Dorfman - 3 years ago 99
iOS Question

Apple CoreData Tutorial: What does 'moc = ...' mean?

In the tutorial on how to fetch data from core data, I found the following code.

What is this

...
operator?
What is this
moc
?

Am I supposed to implement some sort of protocol in order to have access to these special operators?

Thanks for any help
enter image description here

Answer Source

"MOC" in CoreData refers to a managed object context.

Overview

A context consists of a group of related model objects that represent an internally consistent view of one or more persistent stores. Changes to managed objects are held in memory, in the associated context, until that context is saved to one or more persistent stores. A single managed object instance exists in one and only one context, but multiple copies of an object can exist in different contexts. Thus an object is unique to a particular context.

The ... is not actual code, it's just representing that the initialization of the managed object context would go there.

For example:

let moc = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download