GNUstep Core Data
0.1
|
Nn abstract superclass from which concrete implementations of various persistent store types are subclassed. More...
Inherited by GSSQLitePersistentStore.
Public Member Functions | |
(id) | - initWithURL:managedObjectModel:configuration:options: |
The designated initializer. | |
(NSURL *) | - URL |
Getting the store's URL. | |
(NSString *) | - configuration |
Getting the store's configuration. | |
(void) | - setUUID: |
Sets the UUID of the receiver. | |
(void) | - setMetadata: |
Sets the store's metadata dictionary. | |
(NSDictionary *) | - metadata |
Returns the store's metadata. | |
(NSString *) | - storeType |
Subclasses must override this to return the store's type as a string. | |
(NSDictionary *) | - fetchObjectsWithEntity:predicate:error: |
Does a lookup in the store for an object that has `entity' set and matches the provided predicate. | |
(BOOL) | - writeSavingObjects:deletingObjects:error: |
Subclass must override this method. |
Nn abstract superclass from which concrete implementations of various persistent store types are subclassed.
Implementation Notes On Merging
Efficient merging works with the help of so-called object version numbers. A version number is an abstract sequential number kept separately for every object in it's managed object context and in the persistent store. Every time an object is saved, it's storage number is incremented in both the managed object context and then in the persistent store.
The trick is that the managed object context first checks that it's storage numbers are equal to those of the persistent store - that meaning that no other change to the objects has happened in the mean time. If, however, they are lower, there have been changes to objects by some other context working with the same persistent store. In that case the context's merge policy is consulted on how to deal with the conflicting objects:
(NB. There is no difference between a rollback and merge-by-property-store-trump (and overwrite and merge-by-property-object-trump) policy, or at least none that I have been able to make out: both policies cause the in-memory object to adjust to the state in the store (or vice versa), and no perfomance difference occurs, since their evaluation is based on a property-by-property basis. Could somebody please clarify this issue?)
Definition at line 43 of file GSPersistentStore.h.
- (NSString *) configuration |
Getting the store's configuration.
Definition at line 198 of file GSPersistentStore.m.
- (NSDictionary *) fetchObjectsWithEntity: | (NSEntityDescription *) | entity | |
predicate: | (NSPredicate *) | predicate | |
error: | (NSError **) | error | |
Does a lookup in the store for an object that has `entity' set and matches the provided predicate.
Subclasses must override this method in order to implement their type-specific store interaction.
The following example demonstrates the format:
{ <ManagedObjectID-1> = { "AttributeName" = <attribute-value>; "ToOneRelationshipName" = <ManagedObjectID-2>; }; <ManagedObjectID-2> = { "ToManyRelationshipName" = ({ <ManagedObjectID-1>, <ManagedObjectID-2>, ... <ManagedObjectID-n> }); }; ... <ManagedObjectID-n> = { ... }; }
Here "{}" delimit an NSDictionary and "({})" delimit an NSSet, as in the usual property-list syntax.
If no object matches the provided search criteria, an empty array should be returned. Passing entity=nil and predicate=nil should return all the objects in the store. On error, this method should return `nil' and set `error' accordingly.
Definition at line 343 of file GSPersistentStore.m.
- (id) initWithURL: | (NSURL *) | URL | |
managedObjectModel: | (NSManagedObjectModel *) | model | |
configuration: | (NSString *) | configuration | |
options: | (NSDictionary *) | options | |
The designated initializer.
Subclasses should override this method to implement their own necessary initialization (such as open a connection to the provided URL), but only after having invoked the superclass' implementation in order to assure that this abstract superclass is properly initialized.
Definition at line 156 of file GSPersistentStore.m.
- (NSDictionary *) metadata |
Returns the store's metadata.
For further information please see -[GSPersistentStore setMetadata:].
Definition at line 243 of file GSPersistentStore.m.
- (void) setMetadata: | (NSDictionary *) | metadata |
Sets the store's metadata dictionary.
The NSStoreUUIDKey and NSStoreTypeKey are automatically added. If they are already defined in the passed argument they will be overwritten in order to avoid interferrence from external code with the type and store UUID machinery, internal to Core Data.
Definition at line 225 of file GSPersistentStore.m.
- (void) setUUID: | (NSString *) | UUID |
Sets the UUID of the receiver.
Subclasses should invoke this method when the UUID is read from the store. External code should NOT invoke it - this could mess up the store UUID machinery.
Definition at line 208 of file GSPersistentStore.m.
- (NSString *) storeType |
Subclasses must override this to return the store's type as a string.
This information is automatically added by GSPersistentStore to the store's meta-data dictionary as necessary.
Definition at line 292 of file GSPersistentStore.m.
- (NSURL *) URL |
Getting the store's URL.
Definition at line 188 of file GSPersistentStore.m.
- (BOOL) writeSavingObjects: | (NSSet *) | objectsToWrite | |
deletingObjects: | (NSSet *) | objectIDsToDelete | |
error: | (NSError **) | error | |
Subclass must override this method.
It should write the persistent store to it's URL location. In detail, this method must perform this:
It is good practice to somehow 'key' the stored objects in the store against their object IDs (`object' here refers not to an instance of NSManagedObject, but instead to the stored aggregation of persistent properties) - this makes later access to objects easier.
If the write is successful this method should return YES, or, in case an error occured, return NO and indicate the reason for it in `error'.
Definition at line 406 of file GSPersistentStore.m.