Class: NSEntityMigrationPolicy

Inherits:
NSObject show all

Overview

Instances of NSEntityMigrationPolicy customize the migration process for an entity mapping.

Instance Method Summary (collapse)

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

- (Boolean) beginEntityMapping(mapping, manager:manager, error:error)

Invoked by the migration manager at the start of a given entity mapping. This method is the precursor to the creation stage. In a custom class, you can implement this method to set up any state information that will be useful for the duration of the migration.

Parameters:

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the method completes successfully, otherwise NO.

- (Boolean) createDestinationInstancesForSourceInstance(sInstance, entityMapping:mapping, manager:manager, error:error)

Creates the destination instance(s) for a given source instance. This method is invoked by the migration manager on each source instance (as specified by the sourceExpression in the mapping) to create the corresponding destination instance(s). It also associates the source and destination instances by calling NSMigrationManager’s associateSourceInstance:withDestinationInstance:forEntityMapping: method.

Parameters:

  • sInstance (NSManagedObject)

    The source instance for which to create destination instances.

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the method completes successfully, otherwise NO.

- (Boolean) createRelationshipsForDestinationInstance(dInstance, entityMapping:mapping, manager:manager, error:error)

Constructs the relationships between the newly-created destination instances. You can use this stage to (re)create relationships between migrated objects—you use the association lookup methods on the NSMigrationManager instance to determine the appropriate relationship targets.

Parameters:

  • dInstance (NSManagedObject)

    The destination instance for which to create relationships.

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the relationships are constructed correctly, otherwise NO.

- (Boolean) endEntityMapping(mapping, manager:manager, error:error)

Invoked by the migration manager at the end of a given entity mapping. This is the end to the given entity mapping. You can implement this method to perform any clean-up at the end of the migration (from any of the three phases of the mapping).

Parameters:

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the method completes correctly, otherwise NO.

- (Boolean) endInstanceCreationForEntityMapping(mapping, manager:manager, error:error)

Indicates the end of the creation stage for the specified entity mapping, and the precursor to the next migration stage. You can override this method to clean up state from the creation of destination or to prepare state for the creation of relationships.

Parameters:

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the relationships are constructed correctly, otherwise NO.

- (Boolean) endRelationshipCreationForEntityMapping(mapping, manager:manager, error:error)

Indicates the end of the relationship creation stage for the specified entity mapping. This method is invoked after createRelationshipsForDestinationInstance:entityMapping:manager:error:; you can override it to clean up state from the creation of relationships, or prepare state for custom validation in performCustomValidationForEntityMapping:manager:error:.

Parameters:

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the method completes correctly, otherwise NO.

- (Boolean) performCustomValidationForEntityMapping(mapping, manager:manager, error:error)

Invoked during the validation stage of the entity migration policy, providing the option of performing custom validation on migrated objects. This method is called before the default save validation is performed by the framework.If you implement this method, you must manually obtain the collection of objects you are interested in validating.

Parameters:

  • mapping (NSEntityMapping)

    The mapping object in use.

  • manager (NSMigrationManager)

    The migration manager performing the migration.

  • error (Pointer)

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

Returns:

  • (Boolean)

    YES if the method completes correctly, otherwise NO.