Permalink
Browse files

Add completed property to task

  • Loading branch information...
1 parent cae48ce commit 4167aba8f0ee15a590406697a21116edf2f8f3cf @soffes soffes committed Aug 14, 2012
Showing with 22 additions and 7 deletions.
  1. +1 −1 CheddarKit/CDKTask.h
  2. +21 −6 CheddarKit/CDKTask.m
View
2 CheddarKit/CDKTask.h
@@ -25,8 +25,8 @@
@property (nonatomic, strong) CDKUser *user;
@property (nonatomic, strong) CDKList *list;
@property (nonatomic, strong) NSSet *tags;
+@property (nonatomic, assign, getter = isCompleted) BOOL completed;
-- (BOOL)isCompleted;
- (void)toggleCompleted;
- (BOOL)hasTag:(CDKTag *)tag;
- (BOOL)hasTags:(NSArray *)tags;
View
27 CheddarKit/CDKTask.m
@@ -25,6 +25,27 @@ @implementation CDKTask
@dynamic list;
@dynamic tags;
+- (void)setCompleted:(BOOL)completed {
+ if (completed == [self isCompleted]) {
+ return;
+ }
+
+ if (completed) {
+ self.completedAt = [NSDate date];
+ } else {
+ self.completedAt = nil;
+ }
+
+ [self save];
+ [self update];
+}
+
+
+- (BOOL)isCompleted {
+ return self.completedAt != nil;
+}
+
+
#pragma mark - SSManagedObject
+ (NSString *)entityName {
@@ -119,12 +140,6 @@ + (void)sortWithObjects:(NSArray *)objects success:(void(^)(void))success failur
#pragma mark - Task
-
-- (BOOL)isCompleted {
- return self.completedAt != nil;
-}
-
-
- (void)toggleCompleted {
if (self.isCompleted) {
self.completedAt = nil;

0 comments on commit 4167aba

Please sign in to comment.