Permalink
Browse files

delete support

  • Loading branch information...
1 parent 9ab4b1e commit 9d7fd07edd482b6c2eefb091e20d7493bbd5989d @drewcrawford committed Feb 25, 2013
Showing with 12 additions and 0 deletions.
  1. +4 −0 CoreDataHelp/CDHRepo.h
  2. +8 −0 CoreDataHelp/CDHRepo.m
View
@@ -96,6 +96,10 @@ typedef void(^operationBlock)();
-(id) objectWithObjectID:(NSManagedObjectID*) obj;
+/**Marks the object as deleted. The object is not actually deleted until the repository is saved.
+ After the repository is saved, the objects attributes/relationships/values are undefined. */
+-(void) deleteObject:(NSManagedObject*) obj;
+
#ifdef CAFFEINE_IOS_IS_AVAILABLE
- (NSArray*) arrayWithOpaqueResult:(CaffeineOpaqueResult*) opaqueResult;
#endif
View
@@ -10,6 +10,7 @@
#import <DCAKit/DCAKit.h>
#import "CoreDataStack.h"
#import "CoreDataHelpError.h"
+#import "NSManagedObject+CDHRepo.h"
static CDHRepo *rootRepo;
static NSMapTable *reposByMoc;
@@ -151,6 +152,13 @@ - (id)insertInstanceOfClass:(Class)c {
return [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass(c) inManagedObjectContext:_moc];
}
+- (void)deleteObject:(NSManagedObject *)obj {
+ NSAssert(threading_looks_okay, @"Try doing this inside a block.");
+ NSAssert(obj.repo==self, @"Object didn't come from this repo.");
+ [_moc deleteObject:obj];
+
+}
+
#ifdef CAFFEINE_IOS_IS_AVAILABLE
- (NSArray*) arrayWithOpaqueResult:(CaffeineOpaqueResult*) opaqueResult {
NSAssert(threading_looks_okay, @"Try doing this inside a block.");

0 comments on commit 9d7fd07

Please sign in to comment.