Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/CoreDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

@property (copy, nonatomic) NSString *databaseName;
@property (copy, nonatomic) NSString *modelName;
@property (strong, nonatomic) NSBundle *bundle;

+ (id)instance DEPRECATED_ATTRIBUTE;
+ (instancetype)sharedManager;
Expand Down
11 changes: 9 additions & 2 deletions Classes/CoreDataManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ + (instancetype)sharedManager {
#pragma mark - Private

- (NSString *)appName {
return [[NSBundle bundleForClass:[self class]] infoDictionary][@"CFBundleName"];
return [self.bundle infoDictionary][@"CFBundleName"];
}

- (NSString *)databaseName {
Expand Down Expand Up @@ -80,7 +80,7 @@ - (NSManagedObjectContext *)managedObjectContext {
- (NSManagedObjectModel *)managedObjectModel {
if (_managedObjectModel) return _managedObjectModel;

NSURL *modelURL = [[NSBundle bundleForClass:[self class]] URLForResource:[self modelName] withExtension:@"momd"];
NSURL *modelURL = [self.bundle URLForResource:[self modelName] withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}
Expand Down Expand Up @@ -111,6 +111,13 @@ - (BOOL)saveContext {
return YES;
}

- (NSBundle *)bundle {
if (_bundle) return _bundle;

_bundle = [NSBundle bundleForClass:self.class];

return _bundle;
}

#pragma mark - SQLite file directory

Expand Down