Skip to content

Commit

Permalink
s/mneorr.com/supermar.in
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin Usalj committed Mar 20, 2014
1 parent 8bbc92a commit 05be8fa
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Classes/CoreDataManager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// CoreDataManager.h
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 13 additions & 13 deletions Classes/CoreDataManager.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// CoreDataManager.m
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -52,7 +52,7 @@ - (NSString *)appName {

- (NSString *)databaseName {
if (_databaseName != nil) return _databaseName;

_databaseName = [[[self appName] stringByAppendingString:@".sqlite"] copy];
return _databaseName;
}
Expand All @@ -69,7 +69,7 @@ - (NSString *)modelName {

- (NSManagedObjectContext *)managedObjectContext {
if (_managedObjectContext) return _managedObjectContext;

if (self.persistentStoreCoordinator) {
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
[_managedObjectContext setPersistentStoreCoordinator:self.persistentStoreCoordinator];
Expand All @@ -79,15 +79,15 @@ - (NSManagedObjectContext *)managedObjectContext {

- (NSManagedObjectModel *)managedObjectModel {
if (_managedObjectModel) return _managedObjectModel;

NSURL *modelURL = [[NSBundle bundleForClass:[self class]] URLForResource:[self modelName] withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (_persistentStoreCoordinator) return _persistentStoreCoordinator;

_persistentStoreCoordinator = [self persistentStoreCoordinatorWithStoreType:NSSQLiteStoreType
storeURL:[self sqliteStoreURL]];
return _persistentStoreCoordinator;
Expand All @@ -100,22 +100,22 @@ - (void)useInMemoryStore {
- (BOOL)saveContext {
if (self.managedObjectContext == nil) return NO;
if (![self.managedObjectContext hasChanges])return NO;

NSError *error = nil;

if (![self.managedObjectContext save:&error]) {
NSLog(@"Unresolved error in saving context! %@, %@", error, [error userInfo]);
return NO;
}

return YES;
}


#pragma mark - SQLite file directory

- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] lastObject];
}

Expand All @@ -130,23 +130,23 @@ - (NSURL *)applicationSupportDirectory {

- (NSPersistentStoreCoordinator *)persistentStoreCoordinatorWithStoreType:(NSString *const)storeType
storeURL:(NSURL *)storeURL {

NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

NSDictionary *options = @{ NSMigratePersistentStoresAutomaticallyOption: @YES,
NSInferMappingModelAutomaticallyOption: @YES };

NSError *error = nil;
if (![coordinator addPersistentStoreWithType:storeType configuration:nil URL:storeURL options:options error:&error])
NSLog(@"ERROR WHILE CREATING PERSISTENT STORE COORDINATOR! %@, %@", error, [error userInfo]);

return coordinator;
}

- (NSURL *)sqliteStoreURL {
NSURL *directory = [self isOSX] ? self.applicationSupportDirectory : self.applicationDocumentsDirectory;
NSURL *databaseDir = [directory URLByAppendingPathComponent:[self databaseName]];

[self createApplicationSupportDirIfNeeded:directory];
return databaseDir;
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/NSManagedObject+ActiveRecord.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NSManagedObject+ActiveRecord.h
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Classes/NSManagedObject+ActiveRecord.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NSManagedObject+ActiveRecord.m
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Classes/NSManagedObject+Mappings.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NSManagedObject+Mappings.h
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions Classes/NSManagedObject+Mappings.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NSManagedObject+Mappings.m
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -28,15 +28,15 @@
@implementation NSManagedObject (Mappings)

+ (id)keyForRemoteKey:(NSString *)remoteKey {

if (self.cachedMappings[remoteKey])
return self.cachedMappings[remoteKey];

NSString *camelCasedProperty = [remoteKey.camelCase stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:[[remoteKey substringWithRange:NSMakeRange(0, 1)] lowercaseString]];

NSEntityDescription *desc = [NSEntityDescription entityForName:[self entityName] inManagedObjectContext:[NSManagedObjectContext defaultContext]];

if ([desc propertiesByName][camelCasedProperty]) {
self.cachedMappings[remoteKey] = camelCasedProperty;
return camelCasedProperty;
Expand All @@ -55,7 +55,7 @@ + (NSMutableDictionary *)cachedMappings {
mappingsForClass = [self mappings].mutableCopy ?: @{}.mutableCopy;
[NSManagedObject sharedMappings][(id<NSCopying>)self.class] = mappingsForClass;
}

return mappingsForClass;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/ObjectiveRecord.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ObjectiveRecord.h
//
// Copyright (c) 2014 Marin Usalj <http://mneorr.com>
// Copyright (c) 2014 Marin Usalj <http://supermar.in>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 Marin Usalj <http://mneorr.com>
Copyright (c) 2014 Marin Usalj <http://supermar.in>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down

0 comments on commit 05be8fa

Please sign in to comment.