Class: NSManagedObjectModel

Inherits:
NSObject show all

Overview

An NSManagedObjectModel object describes a schema—a collection of entities (data models) that you use in your application.

Class Method Summary (collapse)

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

Class Method Details

+ (NSManagedObjectModel) mergedModelFromBundles(bundles)

Returns a model created by merging all the models found in given bundles.

Parameters:

  • bundles (Array)

    An array of instances of NSBundle to search. If you specify nil, then the main bundle is searched.

Returns:

+ (NSManagedObjectModel) mergedModelFromBundles(bundles, forStoreMetadata:metadata)

Returns a merged model from a specified array for the version information in provided metadata. This method is a companion to mergedModelFromBundles:.

Parameters:

  • bundles (Array)

    An array of bundles.

  • metadata (Hash)

    A dictionary containing version information from the metadata for a persistent store.

Returns:

  • (NSManagedObjectModel)

    The managed object model used to create the store for the metadata. If a model cannot be created to match the version information specified by metadata, returns nil.

+ (NSManagedObjectModel) modelByMergingModels(models)

Creates a single model from an array of existing models. You use this method to combine multiple models (typically from different frameworks) into one.

Parameters:

Returns:

+ (NSManagedObjectModel) modelByMergingModels(models, forStoreMetadata:metadata)

Returns, for the version information in given metadata, a model merged from a given array of models. This is the companion method to mergedModelFromBundles:forStoreMetadata:.

Parameters:

  • models (Array)

    An array of instances of NSManagedObjectModel.

  • metadata (Hash)

    A dictionary containing version information from the metadata for a persistent store.

Returns:

  • (NSManagedObjectModel)

    A merged model from models for the version information in metadata. If a model cannot be created to match the version information in metadata, returns nil.

Instance Method Details

- (Array) configurations

Returns all the available configuration names of the receiver.

Returns:

  • (Array)

    An array containing the available configuration names of the receiver.

- (Array) entities

Returns the entities in the receiver. Entities are instances of NSEntityDescription.

Returns:

  • (Array)

    An array containing the entities in the receiver.

- (Hash) entitiesByName

Returns the entities of the receiver in a dictionary.

Returns:

  • (Hash)

    The entities of the receiver in a dictionary, where the keys in the dictionary are the names of the corresponding entities.

- (Array) entitiesForConfiguration(configuration)

Returns the entities of the receiver for a specified configuration.

Parameters:

  • configuration (String)

    The name of a configuration in the receiver.

Returns:

  • (Array)

    An array containing the entities of the receiver for the configuration specified by configuration.

- (Hash) entityVersionHashesByName

Returns a dictionary of the version hashes for the entities in the receiver. The dictionary of version hash information is used by Core Data to determine schema compatibility.

Returns:

  • (Hash)

    A dictionary of the version hashes for the entities in the receiver, keyed by entity name.

- (NSFetchRequest) fetchRequestFromTemplateWithName(name, substitutionVariables:variables)

Returns a copy of the fetch request template with the variables substituted by values from the substitutions dictionary. The variables dictionary must provide values for all the variables. If you want to test for a nil value, use [NSNull null]. This method provides the usual way to bind an “abstractly” defined fetch request template to a concrete fetch. For more details on using this method, see Creating Predicates.

Parameters:

  • name (String)

    A string containing the name of a fetch request template.

  • variables (Hash)

    A dictionary containing key-value pairs where the keys are the names of variables specified in the template; the corresponding values are substituted before the fetch request is returned. The dictionary must provide values for all the variables in the template.

Returns:

  • (NSFetchRequest)

    A copy of the fetch request template with the variables substituted by values from variables.

- (NSFetchRequest) fetchRequestTemplateForName(name)

Returns the fetch request with a specified name. If the template contains substitution variables, you should instead use fetchRequestFromTemplateWithName:substitutionVariables: to create a new fetch request.

Parameters:

  • name (String)

    A string containing the name of a fetch request template.

Returns:

- (Hash) fetchRequestTemplatesByName

Returns a dictionary of the receiver’s fetch request templates. If the template contains a predicate with substitution variables, you should instead use fetchRequestFromTemplateWithName:substitutionVariables: to create a new fetch request.

Returns:

  • (Hash)

    A dictionary of the receiver’s fetch request templates, keyed by name.

- (Object) initWithContentsOfURL(url)

Initializes the receiver using the model file at the specified URL.

Parameters:

  • url (NSURL)

    An URL object specifying the location of a model file.

Returns:

  • (Object)

    A managed object model initialized using the file at url.

- (Boolean) isConfiguration(configuration, compatibleWithStoreMetadata:metadata)

Returns a Boolean value that indicates whether a given configuration in the receiver is compatible with given metadata from a persistent store. This method compares the version information in the store metadata with the entity versions of a given configuration. For information on specific differences, use entityVersionHashesByName and perform an entity-by-entity comparison.

Parameters:

  • configuration (String)

    The name of a configuration in the receiver. Pass nil to specify no configuration.

  • metadata (Hash)

    Metadata for a persistent store.

Returns:

  • (Boolean)

    YES if the configuration in the receiver specified by configuration is compatible with the store metadata given by metadata, otherwise NO.

- (Hash) localizationDictionary

Returns the localization dictionary of the receiver. The key-value pattern is described in setLocalizationDictionary:.

Returns:

  • (Hash)

    The localization dictionary of the receiver.

- (Object) setEntities(entities)

Sets the entities array of the receiver.

Parameters:

Returns:

- (Object) setEntities(entities, forConfiguration:configuration)

Associates the specified entities with the receiver using the given configuration name.

Parameters:

Returns:

- (Object) setFetchRequestTemplate(fetchRequest, forName:name)

Associates the specified fetch request with the receiver using the given name. For more details on using this method, see Creating Predicates.

Parameters:

  • fetchRequest (NSFetchRequest)

    A fetch request, typically containing predicates with variables for substitution.

  • name (String)

    A string that specifies the name of the fetch request template.

Returns:

- (Object) setLocalizationDictionary(localizationDictionary)

Sets the localization dictionary of the receiver. Table 1 describes the key and value pattern for the localization dictionary.Table 1  Key and value pattern for the localization dictionary.

Key Value Note “Entity/NonLocalizedEntityName” “LocalizedEntityName”

“Property/NonLocalizedPropertyName/Entity/EntityName” “LocalizedPropertyName” (1) “Property/NonLocalizedPropertyName” “LocalizedPropertyName”

“ErrorString/NonLocalizedErrorString” “LocalizedErrorString”

(1) For properties in different entities with the same non-localized name but which should have different localized names.

Parameters:

  • localizationDictionary (Hash)

    A dictionary containing localized string values for entities, properties, and error strings related to the model. The key and value pattern is described in Table 1.

Returns:

- (Object) setVersionIdentifiers(identifiers)

Sets the identifiers for the receiver.

Parameters:

  • identifiers (NSSet)

    An array of identifiers for the receiver.

Returns:

- (NSSet) versionIdentifiers

Returns the collection of developer-defined version identifiers for the receiver. The Core Data framework does not give models a default identifier, nor does it depend this value at runtime. For models created in Xcode, you set this value in the model inspector. This value is meant to be used as a debugging hint to help you determine the models that were combined to create a merged model.

Returns:

  • (NSSet)

    The collection of developer-defined version identifiers for the receiver. Merged models return the combined collection of identifiers.