Inherits from NSObject
Declared in MagicalRecordInternal.h

Overview

Provides class methods to help setup, save, handle errors and provide information about the currently loaded version of MagicalRecord.

Tasks

Other Methods

  • + version

    Returns the current version of MagicalRecord. See the MagicalRecordVersionTag enumeration for valid current and historical values.

  • + currentStack

    Provides information about the current stack, including the model, coordinator, persistent store, the default context and any parent contexts of the default context.

  • + cleanUp

    Cleans up the entire MagicalRecord stack. Sets the default model, store and context to nil before posting a kMagicalRecordCleanedUpNotification notification.

  • + setDefaultModelFromClass:

    Calls NSBundle’s -bundleForClass: to determine the bundle to search for the default model within.

  • + setDefaultModelNamed:

    Looks for a momd file with the specified name, and if found sets it as the default model.

  • + defaultStoreName

    Determines the store file name your app should use. This method is used by the MagicalRecord SQLite stacks when a store file is not specified. The file name returned is in the form “.sqlite”. <ApplicationName> is taken from the application’s info dictionary, which is retrieved from the method [[NSBundle mainBundle] infoDictionary]. If no bundle name is available, “CoreDataStore.sqlite” will be used.

Actions Methods

Setup Methods

ActionsDeprecated Methods

iCloud Methods

ErrorHandling Methods

ShorthandMethods Methods

Options Methods

  • + shouldAutoCreateManagedObjectModel

    If this is true, the default managed object model will be automatically created if it doesn’t exist when calling [NSManagedObjectModel MR_defaultManagedObjectModel].

  • + setShouldAutoCreateManagedObjectModel:

    Setting this to true will make MagicalRecord create the default managed object model automatically if it doesn’t exist when calling [NSManagedObjectModel MR_defaultManagedObjectModel].

  • + shouldAutoCreateDefaultPersistentStoreCoordinator

    If this is true, the default persistent store will be automatically created if it doesn’t exist when calling [NSPersistentStoreCoordinator MR_defaultStoreCoordinator].

  • + setShouldAutoCreateDefaultPersistentStoreCoordinator:

    Setting this to true will make MagicalRecord create the default persistent store automatically if it doesn’t exist when calling [NSPersistentStoreCoordinator MR_defaultStoreCoordinator].

  • + shouldDeleteStoreOnModelMismatch

    If this is true and MagicalRecord encounters a store with a version that does not match that of the model, the store will be removed from the disk. This is extremely useful during development where frequent model changes can potentially require a delete and reinstall of the app.

  • + setShouldDeleteStoreOnModelMismatch:

    Setting this to true will make MagicalRecord delete any stores that it encounters which do not match the version of their model. This is extremely useful during development where frequent model changes can potentially require a delete and reinstall of the app.

  • + loggingLevel

    Returns the logging mask set for MagicalRecord in the current application.

  • + setLoggingLevel:

    Sets the logging mask set for MagicalRecord in the current application.

Class Methods

cleanUp

+ (void)cleanUp
Discussion

Cleans up the entire MagicalRecord stack. Sets the default model, store and context to nil before posting a kMagicalRecordCleanedUpNotification notification.

Availability

Available in v1.0 and later.

Declared In

MagicalRecordInternal.h

currentStack

+ (NSString *)currentStack
Discussion

Provides information about the current stack, including the model, coordinator, persistent store, the default context and any parent contexts of the default context.

Return Value

Description of the current state of the stack.

Availability

Available in v2.3 and later.

Declared In

MagicalRecordInternal.h

defaultStoreName

+ (NSString *)defaultStoreName
Discussion

Determines the store file name your app should use. This method is used by the MagicalRecord SQLite stacks when a store file is not specified. The file name returned is in the form “.sqlite”. <ApplicationName> is taken from the application’s info dictionary, which is retrieved from the method [[NSBundle mainBundle] infoDictionary]. If no bundle name is available, “CoreDataStore.sqlite” will be used.

Return Value

String of the form .sqlite

Availability

Available in v2.0 and later.

Declared In

MagicalRecordInternal.h

enableShorthandMethods

+ (void)enableShorthandMethods

errorHandlerAction

+ (SEL)errorHandlerAction

errorHandlerTarget

+ (id)errorHandlerTarget

handleErrors:

+ (void)handleErrors:(NSError *)error

isICloudEnabled

+ (BOOL)isICloudEnabled

loggingLevel

+ (MagicalRecordLoggingLevel)loggingLevel
Discussion

Returns the logging mask set for MagicalRecord in the current application.

Return Value

Availability

Available in v2.3 and later.

Declared In

MagicalRecord+Options.h

saveInBackgroundUsingCurrentContextWithBlock:completion:errorHandler:

+ (void)saveInBackgroundUsingCurrentContextWithBlock:(void ( ^ ) ( NSManagedObjectContext *localContext ))block completion:(void ( ^ ) ( void ))completion errorHandler:(void ( ^ ) ( NSError *error ))errorHandler

saveInBackgroundWithBlock:

+ (void)saveInBackgroundWithBlock:(void ( ^ ) ( NSManagedObjectContext *localContext ))block

saveInBackgroundWithBlock:completion:

+ (void)saveInBackgroundWithBlock:(void ( ^ ) ( NSManagedObjectContext *localContext ))block completion:(void ( ^ ) ( void ))completion

saveUsingCurrentThreadContextWithBlock:completion:

+ (void)saveUsingCurrentThreadContextWithBlock:(void ( ^ ) ( NSManagedObjectContext *localContext ))block completion:(MRSaveCompletionHandler)completion

saveUsingCurrentThreadContextWithBlockAndWait:

+ (void)saveUsingCurrentThreadContextWithBlockAndWait:(void ( ^ ) ( NSManagedObjectContext *localContext ))block

saveWithBlock:

+ (void)saveWithBlock:(void ( ^ ) ( NSManagedObjectContext *localContext ))block

saveWithBlock:completion:

+ (void)saveWithBlock:(void ( ^ ) ( NSManagedObjectContext *localContext ))block completion:(MRSaveCompletionHandler)completion

saveWithBlockAndWait:

+ (void)saveWithBlockAndWait:(void ( ^ ) ( NSManagedObjectContext *localContext ))block

setDefaultModelFromClass:

+ (void)setDefaultModelFromClass:(Class)modelClass
Discussion

Calls NSBundle’s -bundleForClass: to determine the bundle to search for the default model within.

Parameters

modelClass

Class to set the model from

Availability

Available in v2.0 and later.

Declared In

MagicalRecordInternal.h

setDefaultModelNamed:

+ (void)setDefaultModelNamed:(NSString *)modelName
Discussion

Looks for a momd file with the specified name, and if found sets it as the default model.

Parameters

modelName

Model name as a string, including file extension

Availability

Available in v1.0 and later.

Declared In

MagicalRecordInternal.h

setErrorHandlerTarget:action:

+ (void)setErrorHandlerTarget:(id)target action:(SEL)action

setLoggingLevel:

+ (void)setLoggingLevel:(MagicalRecordLoggingLevel)level
Discussion

Sets the logging mask set for MagicalRecord in the current application.

Parameters

level

Any value from MagicalRecordLogLevel

Availability

Available in v2.3 and later.

Declared In

MagicalRecord+Options.h

setShouldAutoCreateDefaultPersistentStoreCoordinator:

+ (void)setShouldAutoCreateDefaultPersistentStoreCoordinator:(BOOL)autoCreate
Discussion

Setting this to true will make MagicalRecord create the default persistent store automatically if it doesn’t exist when calling [NSPersistentStoreCoordinator MR_defaultStoreCoordinator].

Parameters

autoCreate

BOOL value that flags whether the default persistent store should be automatically created.

Availability

Available in v2.0.4 and later.

Declared In

MagicalRecord+Options.h

setShouldAutoCreateManagedObjectModel:

+ (void)setShouldAutoCreateManagedObjectModel:(BOOL)autoCreate
Discussion

Setting this to true will make MagicalRecord create the default managed object model automatically if it doesn’t exist when calling [NSManagedObjectModel MR_defaultManagedObjectModel].

Parameters

autoCreate

BOOL value that flags whether the default persistent store should be automatically created.

Availability

Available in v2.0.4 and later.

Declared In

MagicalRecord+Options.h

setShouldDeleteStoreOnModelMismatch:

+ (void)setShouldDeleteStoreOnModelMismatch:(BOOL)shouldDelete
Discussion

Setting this to true will make MagicalRecord delete any stores that it encounters which do not match the version of their model. This is extremely useful during development where frequent model changes can potentially require a delete and reinstall of the app.

Parameters

shouldDelete

BOOL value that flags whether mismatched stores should be deleted

Availability

Available in v2.0.4 and later.

Declared In

MagicalRecord+Options.h

setupAutoMigratingCoreDataStack

+ (void)setupAutoMigratingCoreDataStack

setupCoreDataStack

+ (void)setupCoreDataStack

setupCoreDataStackWithAutoMigratingSqliteStoreAtURL:

+ (void)setupCoreDataStackWithAutoMigratingSqliteStoreAtURL:(NSURL *)storeURL

setupCoreDataStackWithAutoMigratingSqliteStoreNamed:

+ (void)setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(NSString *)storeName

setupCoreDataStackWithInMemoryStore

+ (void)setupCoreDataStackWithInMemoryStore

setupCoreDataStackWithStoreAtURL:

+ (void)setupCoreDataStackWithStoreAtURL:(NSURL *)storeURL

setupCoreDataStackWithStoreNamed:

+ (void)setupCoreDataStackWithStoreNamed:(NSString *)storeName

setupCoreDataStackWithiCloudContainer:contentNameKey:localStoreAtURL:cloudStorePathComponent:

+ (void)setupCoreDataStackWithiCloudContainer:(NSString *)containerID contentNameKey:(NSString *)contentNameKey localStoreAtURL:(NSURL *)storeURL cloudStorePathComponent:(NSString *)pathSubcomponent

setupCoreDataStackWithiCloudContainer:contentNameKey:localStoreAtURL:cloudStorePathComponent:completion:

+ (void)setupCoreDataStackWithiCloudContainer:(NSString *)containerID contentNameKey:(NSString *)contentNameKey localStoreAtURL:(NSURL *)storeURL cloudStorePathComponent:(NSString *)pathSubcomponent completion:(void ( ^ ) ( void ))completion

setupCoreDataStackWithiCloudContainer:contentNameKey:localStoreNamed:cloudStorePathComponent:

+ (void)setupCoreDataStackWithiCloudContainer:(NSString *)containerID contentNameKey:(NSString *)contentNameKey localStoreNamed:(NSString *)localStoreName cloudStorePathComponent:(NSString *)pathSubcomponent

setupCoreDataStackWithiCloudContainer:contentNameKey:localStoreNamed:cloudStorePathComponent:completion:

+ (void)setupCoreDataStackWithiCloudContainer:(NSString *)containerID contentNameKey:(NSString *)contentNameKey localStoreNamed:(NSString *)localStoreName cloudStorePathComponent:(NSString *)pathSubcomponent completion:(void ( ^ ) ( void ))completion

setupCoreDataStackWithiCloudContainer:localStoreAtURL:

+ (void)setupCoreDataStackWithiCloudContainer:(NSString *)containerID localStoreAtURL:(NSURL *)storeURL

setupCoreDataStackWithiCloudContainer:localStoreNamed:

+ (void)setupCoreDataStackWithiCloudContainer:(NSString *)containerID localStoreNamed:(NSString *)localStore

shouldAutoCreateDefaultPersistentStoreCoordinator

+ (BOOL)shouldAutoCreateDefaultPersistentStoreCoordinator
Discussion

If this is true, the default persistent store will be automatically created if it doesn’t exist when calling [NSPersistentStoreCoordinator MR_defaultStoreCoordinator].

Return Value

current value of shouldAutoCreateDefaultPersistentStoreCoordinator.

Availability

Available in v2.0.4 and later.

Declared In

MagicalRecord+Options.h

shouldAutoCreateManagedObjectModel

+ (BOOL)shouldAutoCreateManagedObjectModel
Discussion

If this is true, the default managed object model will be automatically created if it doesn’t exist when calling [NSManagedObjectModel MR_defaultManagedObjectModel].

Return Value

current value of shouldAutoCreateManagedObjectModel.

Availability

Available in v2.0.4 and later.

Declared In

MagicalRecord+Options.h

shouldDeleteStoreOnModelMismatch

+ (BOOL)shouldDeleteStoreOnModelMismatch
Discussion

If this is true and MagicalRecord encounters a store with a version that does not match that of the model, the store will be removed from the disk. This is extremely useful during development where frequent model changes can potentially require a delete and reinstall of the app.

Return Value

current value of shouldDeleteStoreOnModelMismatch

Availability

Available in v2.0.4 and later.

Declared In

MagicalRecord+Options.h

version

+ (MagicalRecordVersionTag)version
Discussion

Returns the current version of MagicalRecord. See the MagicalRecordVersionTag enumeration for valid current and historical values.

Return Value

The current version as a double.

Availability

Available in v2.3 and later.

Declared In

MagicalRecordInternal.h

Instance Methods

handleErrors:

- (void)handleErrors:(NSError *)error