Skip to content

Basic yet powerful CoreData Stack

Latest
Compare
Choose a tag to compare
@ssuchanowski ssuchanowski released this 16 Jun 12:38
· 4 commits to master since this release
  • encapsulating all core data stack in one class
  • multithreaded managed object context without pain (if you don't do any massive imports you don't even have to think about multiple contexts, use one for everything and we will do background saves for you)
  • easily create new (temporary) private child managed object context for massive imports (reference: Marcus Zarra Core Data Stack)
  • added protocol to mark all classes that should use SSPersistenceController (I encourage doing it by property injecting and not using AppDelegate as an access to all globally used methods - I did that as well before)
  • NSManagedObject category:
+ (NSString *)entityClassName

(so you won't use it as a string - it's bad)

  • NSManagedObjectContext category (CRUD helper methods):
- (NSArray *)fetchAllEntities:(Class)entityClass 
withPredicate:(NSPredicate *)predicate 
withSorting:(NSSortDescriptor *)sort 
fetchLimit:(NSUInteger)limit 
prefetchRelations:(NSArray *)prefetchRelations 
fetchProperties:(NSArray *)properties;

- (NSManagedObject *)fetchEntity:(Class)entityClass 
withPredicate:(NSPredicate *)predicate 
prefetchRelations:(NSArray *)prefetchRelations;

- (NSInteger)countAllEntities:(Class)entityClass withPredicate:(NSPredicate *)predicate;

- (NSManagedObject *)insertNewObject:(Class)entityClass;