-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACDueDate.m
58 lines (45 loc) · 1.41 KB
/
ACDueDate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// ACDueDate.m
// Accomplish
//
// Created by Shrijit Singh on 14/02/16.
// Copyright © 2016 Shrijit Singh. All rights reserved.
//
#import "ACDueDate.h"
#import "ACTask.h"
#import "SSCoreData.h"
#import "UIApplication+CoreData.h"
#import "NSDateFormatter+HelperMethods.h"
@implementation ACDueDate
+(ACDueDate *)insertDueDateWithDate:(NSDate *)date
{
ACDueDate *coreDataDueDate = [SSCoreData insertNewObjectForEntityForName:@"DueDate"];
coreDataDueDate.date = date;
[[NSDateFormatter sharedDateFormatter] setDateStyle:NSDateFormatterMediumStyle];
coreDataDueDate.dateString = [[NSDateFormatter sharedDateFormatter] stringFromDate:date];
[ACDueDate saveDueDate];
return coreDataDueDate;
}
+(void)saveDueDate
{
NSError *error = nil;
if (![[UIApplication applicationManagedObjectContext] save:&error])
{
NSLog(@"Error occured while saving category");
}
}
//+(NSArray *)fetchDueDates {
// NSArray *dates = [SSCoreData fetchObjectsForEntityForName:@"DueDate" withSortDescriptors:@[[[NSSortDescriptor alloc] initWithKey:@"date"
// ascending:YES]]];
// return dates;
//}
+(void)removeDueDates:(NSArray *)dates
{
// [SSCoreData removeObjects:dates];
[ACDueDate saveDueDate];
}
-(void)removeDueDate
{
[ACDueDate removeDueDates:@[self]];
}
@end