Skip to content

Instantly share code, notes, and snippets.

@kean
Last active June 18, 2016 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kean/207d95d6d3bb1baa57f914353960166a to your computer and use it in GitHub Desktop.
Save kean/207d95d6d3bb1baa57f914353960166a to your computer and use it in GitHub Desktop.
DFCoreDataMigration.h
// The MIT License (MIT)
//
// Copyright (c) 2016 Alexander Grebenyuk (github.com/kean).
#import <CoreData/CoreData.h>
extern NSString *__nonnull const DFMigrationErrorDomain;
typedef NS_ENUM(NSInteger, DFMigrationError) {
DFMigrationErrorSourceModelNotFound = 1,
DFMigrationErrorMappingModelNotFound = 2,
};
@interface DFMigrationManager : NSObject
@property (nonnull, nonatomic, copy, readonly) NSURL *storeURL;
@property (nonnull, nonatomic, copy, readonly) NSString *storeType;
@property (nonnull, nonatomic, copy, readonly) NSArray<NSManagedObjectModel *> *moms;
/*! The name of the managed object model configuration used to create the persistent store. Default value is nil.
*/
@property (nullable, nonatomic, copy) NSString *storeConfiguraton;
/*! Store's options dictionary. Default value is nil.
*/
@property (nullable, nonatomic, copy) NSDictionary *storeOptions;
/*! Bundles which are used to lookup mapping models. Defaults values in @[[NSBundle mainBundle]]
*/
@property (nullable, nonatomic, copy) NSArray<NSBundle *> *bundles;
- (nonnull instancetype)initWithStoreURL:(nonnull NSURL *)storeURL storeType:(nonnull NSString *)storeType orderedModels:(nonnull NSArray<NSManagedObjectModel *> *)models NS_DESIGNATED_INITIALIZER;
+ (nonnull instancetype)new __attribute__((unavailable("Unavailable")));
- (nonnull instancetype)init __attribute__((unavailable("Unavailable")));
- (BOOL)migrate:(NSError *_Nullable *_Nullable)error;
@end
@interface DFMigrationManager (Convenience)
+ (BOOL)migrateStoreAtURL:(nonnull NSURL *)storeURL storeType:(nonnull NSString *)storeType orderedModels:(nonnull NSArray<NSManagedObjectModel *> *)models error:(NSError *_Nullable *_Nullable)error;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment