Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Add tag checking to task
Browse files Browse the repository at this point in the history
It's kinda horrible, but whatever
  • Loading branch information
soffes committed Jul 31, 2012
1 parent cc92e95 commit 390d10f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CheddarKit/CDKTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- (BOOL)isCompleted;
- (void)toggleCompleted;
- (BOOL)hasTag:(CDKTag *)tag;
- (BOOL)hasTags:(NSArray *)tags;

@end

Expand Down
21 changes: 20 additions & 1 deletion CheddarKit/CDKTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,26 @@ - (void)toggleCompleted {


- (BOOL)hasTag:(CDKTag *)tag {
return [self.tags containsObject:tag];
// There has to be a better way to write this
NSArray *names = [self.tags valueForKey:@"name"];
NSString *tagName = [tag.name lowercaseString];
for (NSString *name in names) {
if ([[name lowercaseString] isEqualToString:tagName]) {
return YES;
}
}
return NO;
}


- (BOOL)hasTags:(NSArray *)tags {
// There has to be a better way to write this
for (CDKTag *tag in tags) {
if (![self hasTag:tag]) {
return NO;
}
}
return YES;
}

@end

0 comments on commit 390d10f

Please sign in to comment.