Inherits from NSObject
Declared in RLMMigration.h
RLMMigration.mm

Overview

RLMMigration is the object passed into a user defined RLMMigrationBlock when updating the version of an RLMRealm instance.

This object provides access to the RLMSchema current to this migration.

Properties

newSchema

Get the new RLMSchema for the migration. This is the schema which describes the RLMRealm after applying a migration.

@property (nonatomic, readonly) RLMSchema *newSchema

Declared In

RLMMigration.h

oldSchema

Get the new RLMSchema for the migration. This is the schema which describes the RLMRealm before the migration is applied.

@property (nonatomic, readonly) RLMSchema *oldSchema

Declared In

RLMMigration.h

Instance Methods

createObject:withValue:

Create an RLMObject of type className in the Realm being migrated.

- (RLMObject *)createObject:(NSString *)className withValue:(id)value

Parameters

className

The name of the RLMObject class to create.

value

The value used to populate the created object. This can be any key/value coding compliant object, or a JSON object such as those returned from the methods in NSJSONSerialization, or an NSArray with one object for each persisted property. An exception will be thrown if any required properties are not present and no default is set.

                When passing in an NSArray, all properties must be present, valid and in the same order as the properties defined in the model.

Declared In

RLMMigration.h

deleteDataForClassName:

Deletes the data for the class with the given name. This deletes all objects of the given class, and if the RLMObject subclass no longer exists in your program, cleans up any remaining metadata for the class in the Realm file.

- (BOOL)deleteDataForClassName:(NSString *)name

Parameters

name

The name of the RLMObject class to delete.

Return Value

whether there was any data to delete.

Declared In

RLMMigration.h

deleteObject:

Delete an object from a Realm during a migration. This can be called within enumerateObjects:block:.

- (void)deleteObject:(RLMObject *)object

Parameters

object

Object to be deleted from the Realm being migrated.

Declared In

RLMMigration.h

enumerateObjects:block:

Enumerates objects of a given type in this Realm, providing both the old and new versions of each object. Objects properties can be accessed using keyed subscripting.

- (void)enumerateObjects:(NSString *)className block:(RLMObjectMigrationBlock)block

Parameters

className

The name of the RLMObject class to enumerate.

Discussion

Warning: All objects returned are of a type specific to the current migration and should not be casted to className. Instead you should access them as RLMObjects and use keyed subscripting to access properties.

Declared In

RLMMigration.h