Class: NSAtomicStore
- Inherits:
-
NSPersistentStore
- Object
- NSObject
- NSPersistentStore
- NSAtomicStore
Overview
NSAtomicStore is an abstract superclass that you can subclass to create a Core Data atomic store. It provides default implementations of some utility methods. You use a custom atomic store if you have a custom file format that you want to integrate with a Core Data application.
Instance Method Summary (collapse)
-
- addCacheNodes:
Registers a set of cache nodes with the receiver.
-
- cacheNodeForObjectID:
Returns the cache node for a given managed object ID.
-
- cacheNodes
Returns the set of cache nodes registered with the receiver.
-
- initWithPersistentStoreCoordinator:configurationName:URL:options:
Returns an atomic store, initialized with the given arguments.
-
- load:
Loads the cache nodes for the receiver.
-
- metadata
Returns the metadata for the receiver.
-
- newCacheNodeForManagedObject:
Returns a new cache node for a given managed object.
-
- newReferenceObjectForManagedObject:
Returns a new reference object for a given managed object.
-
- objectIDForEntity:referenceObject:
Returns a managed object ID from the reference data for a specified entity.
-
- referenceObjectForObjectID:
Returns the reference object for a given managed object ID.
-
- save:
Saves the cache nodes.
-
- setMetadata:
Sets the metadata for the receiver.
-
- updateCacheNode:fromManagedObject:
Updates the given cache node using the values in a given managed object.
-
- willRemoveCacheNodes:
Method invoked before the store removes the given collection of cache nodes.
Methods inherited from NSPersistentStore
#URL, #configurationName, #didAddToPersistentStoreCoordinator:, #identifier, #isReadOnly, #loadMetadata:, metadataForPersistentStoreWithURL:error:, migrationManagerClass, #options, #persistentStoreCoordinator, #setIdentifier:, setMetadata:forPersistentStoreWithURL:error:, #setReadOnly:, #setURL:, #type, #willRemoveFromPersistentStoreCoordinator:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Method Details
- (Object) addCacheNodes(cacheNodes)
Registers a set of cache nodes with the receiver. You should invoke this method in a subclass during the call to load: to register the loaded information with the store.
- (NSAtomicStoreCacheNode) cacheNodeForObjectID(objectID)
Returns the cache node for a given managed object ID. This method is normally used by cache nodes to locate related cache nodes (by relationships).
- (NSSet) cacheNodes
Returns the set of cache nodes registered with the receiver.
You should modify this collection using addCacheNodes |
and willRemoveCacheNodes:. |
- (Object) initWithPersistentStoreCoordinator(coordinator, configurationName:configurationName, URL:url, options:options)
Returns an atomic store, initialized with the given arguments. You typically do not invoke this method yourself; it is invoked by the persistent store coordinator during addPersistentStoreWithType:configuration:URL:options:error:, both when a new store is created and when an existing store is opened.In your implementation, you should check whether a file already exists at url; if it does not, then you should either create a file here or ensure that your load: method does not fail if the file does not exist.Any subclass of NSAtomicStore must be able to handle being initialized with a URL pointing to a zero-length file. This serves as an indicator that a new store is to be constructed at the specified location and allows you to securely create reservation files in known locations which can then be passed to Core Data to construct stores. You may choose to create zero-length reservation files during initWithPersistentStoreCoordinator:configurationName:URL:options: or load:. If you do so, you must remove the reservation file if the store is removed from the coordinator before it is saved.You should ensure that you load metadata during initialization and set it using setMetadata:.
- (Boolean) load(error)
Loads the cache nodes for the receiver. You override this method to to load the data from the URL specified in initWithPersistentStoreCoordinator:configurationName:URL:options: and create cache nodes for the represented objects. You must respect the configuration specified for the store, as well as the options. Any subclass of NSAtomicStore must be able to handle being initialized with a URL pointing to a zero-length file. This serves as an indicator that a new store is to be constructed at the specified location and allows you to securely create reservation files in known locations which can then be passed to Core Data to construct stores. You may choose to create zero-length reservation files during initWithPersistentStoreCoordinator:configurationName:URL:options: or load:. If you do so, you must remove the reservation file if the store is removed from the coordinator before it is saved.
- (Hash) metadata
Returns the metadata for the receiver. NSAtomicStore provides a default dictionary of metadata. This dictionary contains the store type and identifier (NSStoreTypeKey and NSStoreUUIDKey) as well as store versioning information. Subclasses must ensure that the metadata is saved along with the store data.
- (NSAtomicStoreCacheNode) newCacheNodeForManagedObject(managedObject)
Returns a new cache node for a given managed object. This method is invoked by the framework after a save operation on a managed object content, once for each newly-inserted NSManagedObject instance.NSAtomicStore provides a default implementation that returns a suitable cache node. You can override this method to take the information from the managed object and return a custom cache node.
- (Object) newReferenceObjectForManagedObject(managedObject)
Returns a new reference object for a given managed object. This method is invoked by the framework after a save operation on a managed object context, once for each newly-inserted managed object. The value returned is used to create a permanent ID for the object and must be unique for an instance within its entity's inheritance hierarchy (in this store).
- (NSManagedObjectID) objectIDForEntity(entity, referenceObject:data)
Returns a managed object ID from the reference data for a specified entity. You use this method to create managed object IDs which are then used to create cache nodes for information being loaded into the store.
- (Object) referenceObjectForObjectID(objectID)
Returns the reference object for a given managed object ID. Subclasses should invoke this method to extract the reference data from the object ID for each cache node if the data is to be made persistent.
- (Boolean) save(error)
Saves the cache nodes. You override this method to make persistent the necessary information from the cache nodes to the URL specified for the receiver.
- (Object) setMetadata(storeMetadata)
Sets the metadata for the receiver.
- (Object) updateCacheNode(node, fromManagedObject:managedObject)
Updates the given cache node using the values in a given managed object. This method is invoked by the framework after a save operation on a managed object context, once for each updated NSManagedObject instance.You override this method in a subclass to take the information from managedObject and update node.
- (Object) willRemoveCacheNodes(cacheNodes)
Method invoked before the store removes the given collection of cache nodes. This method is invoked by the store before the call to save: with the collection of cache nodes marked as deleted by a managed object context. You can override this method to track the nodes which will not be made persistent in the save: method.You should not invoke this method directly in a subclass.