Class: NSIncrementalStore

Inherits:
NSPersistentStore show all

Overview

NSIncrementalStore is an abstract superclass defining the API through which Core Data communicates with a store. This interface is designed to allow you to create persistent stores which load and save data incrementally, allowing for the management of large and/or shared datasets.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSPersistentStore

#URL, #configurationName, #didAddToPersistentStoreCoordinator:, #identifier, #initWithPersistentStoreCoordinator:configurationName:URL:options:, #isReadOnly, #metadata, metadataForPersistentStoreWithURL:error:, migrationManagerClass, #options, #persistentStoreCoordinator, #setIdentifier:, #setMetadata:, 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

Class Method Details

+ (Object) identifierForNewStoreAtURL(storeURL)

Returns the identifier for the store at a given URL.

Parameters:

  • storeURL (NSURL)

    The URL of a persistent store.

Returns:

  • (Object)

    The identifier for the store at storeURL.

Instance Method Details

- (Object) executeRequest(request, withContext:context, error:error)

Returns a value as appropriate for the given request, or nil if the request cannot be completed. The value to return depends on the result type (see resultType) of request:If it is NSManagedObjectResultType, NSManagedObjectIDResultType, or NSDictionaryResultType, the method should return an array containing all objects in the store matching the request.If it is NSCountResultType, the method should return an array containing an NSNumber whose value is the count of of all objects in the store matching the request.If the request is a save request, the method should return an empty array.If the save request contains nil values for the inserted/updated/deleted/locked collections; you should treat it as a request to save the store metadata.You should implement this method conservatively, and expect that unknown request types may at some point be passed to the method. The correct behavior in these cases is to return nil and an error.

Parameters:

Returns:

  • (Object)

    A value as appropriate for request, or nil if the request cannot be completed

- (Boolean) loadMetadata(error)

Loads the metadata for the store. In your implementation of this method, you must validate that the URL used to create the store is usable (the location exists and if necessary is writable, the schema is compatible, and so on) and return an error if there is an issue. Any subclass of NSIncrementalStore which is file-based 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 applications using the store to securely create reservation files in known locations.

Parameters:

  • error (Pointer)

    If an error occurs, on return contains an NSError object that describes the problem.

Returns:

  • (Boolean)

    YES if the metadata was correctly loaded, otherwise NO.

- (Object) managedObjectContextDidRegisterObjectsWithIDs(objectIDs)

Indicates that objects identified by a given array of object IDs are in use in a managed object context. This method and managedObjectContextDidUnregisterObjectsWithIDs: allow managed object contexts to communicate interest in the row data of specific objects in a manner akin to reference counting. For more details, see managedObjectContextDidUnregisterObjectsWithIDs:.

Parameters:

  • objectIDs (Array)

    An array of object IDs.

Returns:

- (Object) managedObjectContextDidUnregisterObjectsWithIDs(objectIDs)

Indicates that objects identified by a given array of object IDs are no longer being used by a managed object context. This method is the counterpart to managedObjectContextDidRegisterObjectsWithIDs:. Passing an object ID in the object IDs array of managedObjectContextDidRegisterObjectsWithIDs: is akin to incrementing the object ID’s reference count by 1; passing an object ID in the object IDs array of managedObjectContextDidUnregisterObjectsWithIDs: is akin to decrementing the object ID’s reference count by 1. It is only when an object ID’s reference count is 0 that no contexts indicate that they are using the corresponding managed object. (Object IDs start with a reference count of 0.) For example, if the register methods is invoked on two occasions when the object IDs array contains a given object ID, and the unregister method is invoked once when the object IDs array contains that object ID, then a context is still using the object with the given ID.

Parameters:

  • objectIDs (Array)

    An array of object IDs.

Returns:

- (NSManagedObjectID) newObjectIDForEntity(entity, referenceObject:data)

Returns a new object ID that uses given data as the key. You should not override this method.

Parameters:

Returns:

  • (NSManagedObjectID)

    A new object ID for an instance of the entity specified by entity and that uses data as the key.

- (Object) newValueForRelationship(relationship, forObjectWithID:objectID, withContext:context, error:error)

Returns the relationship for the given relationship of the object with a given object ID. If the relationship is a to-one, the method should return an NSManagedObjectID instance that identifies the destination, or an instance of NSNull if the relationship value is nil.If the relationship is a to-many, the method should return a collection object containing NSManagedObjectID instances to identify the related objects. Using an NSArray instance is preferred because it will be the most efficient. A store may also return an instance of NSSet or NSOrderedSet; an instance of NSDictionary is not acceptable.If an object with object ID objectID cannot be found, the method should return nil and—if error is not NULL—create and return an appropriate error object in error.

Parameters:

Returns:

  • (Object)

    The value of the relationship specified relationship of the object with object ID objectID, or nil if an error occurs.

- (NSIncrementalStoreNode) newValuesForObjectWithID(objectID, withContext:context, error:error)

Returns an incremental store node encapsulating the persistent external values of the object with a given object ID. The returned node should include all attributes values and may include to-one relationship values as instances of NSManagedObjectID.If an object with object ID objectID cannot be found, the method should return nil and—if error is not NULL—create and return an appropriate error object in error.

Parameters:

  • objectID (NSManagedObjectID)

    The ID of the object for which values are requested.

  • context (NSManagedObjectContext)

    The managed object context into which values will be returned.

  • error (Pointer)

    If an error occurs, upon return contains an NSError object that describes the problem.

Returns:

  • (NSIncrementalStoreNode)

    An incremental store node encapsulating the persistent external values of the object with object ID objectID, or nil if the corresponding object cannot be found.

- (Array) obtainPermanentIDsForObjects(array, error:error)

Returns an array containing the object IDs for a given array of newly-inserted objects. This method is called before executeRequest:withContext:error: with a save request, to assign permanent IDs to newly-inserted objects.

Parameters:

  • array (Array)

    An array of newly-inserted objects.

  • error (Pointer)

    If an error occurs, upon return contains an NSError object that describes the problem.

Returns:

  • (Array)

    An array containing the object IDs for the objects in array.The returned array must return the object IDs in the same order as the objects appear in array.

- (Object) referenceObjectForObjectID(objectID)

Returns the reference data used to construct a given object ID. This method raises an NSInvalidArgumentException if the object ID was not created by the receiving store.You should not override this method.

Parameters:

Returns:

  • (Object)

    The reference data used to construct objectID.