-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemFilter.m
102 lines (83 loc) · 2.62 KB
/
ItemFilter.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// ItemFilter.m
// daily Expenses
//
// Created by Renan Veloso Silva on 30/07/13.
// Copyright (c) 2013 renan veloso silva. All rights reserved.
//
#import "ItemFilter.h"
#import "ItemModel.h"
@implementation ItemFilter
@synthesize monthList;
static id _instance;
+ (ItemFilter *) sharedInstance{
@synchronized(self){
if (!_instance) {
_instance = [[self alloc] init];
}
}
return _instance;
}
-(id)init{
self = [super init];
if (self) {
[self getMonthList];
}
return self;
}
-(NSArray*)filterByLabel:(NSMutableArray*)list ascending:(BOOL)asc{
NSArray *newList;
NSSortDescriptor *descriptor;
descriptor = [NSSortDescriptor sortDescriptorWithKey:@"label" ascending:asc];
newList = [list sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
return newList;
}
-(NSArray*)filterByCreatedDate:(NSMutableArray*)list ascending:(BOOL)asc{
NSArray *newList;
NSSortDescriptor *descriptor;
descriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateCreated" ascending:asc];
newList = [list sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
return newList;
}
-(NSArray*)filterBySpentDate:(NSMutableArray*)list ascending:(BOOL)asc{
NSArray *newList;
NSSortDescriptor *descriptor;
descriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateSpent" ascending:asc];
newList = [list sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
return newList;
}
-(NSArray*)filterByDate:(NSString*)date onList:(NSMutableArray*)list{
NSArray *newList;
NSMutableArray *tempList = [[NSMutableArray alloc] init];
for (ItemModel *itemR in list) {
if ([itemR.dateSpent isEqualToString:date]) {
[tempList addObject:itemR];
}
}
newList = [NSArray arrayWithArray:tempList];
return newList;
}
-(NSArray*)getMonthList{
self.monthList = [NSArray arrayWithObjects:
@"janeiro",
@"fevereiro",
@"março",
@"abril",
@"maio",
@"junho",
@"julho",
@"agosto",
@"setembro",
@"outubro",
@"novembro",
@"dezembro",nil];
return monthList;
}
-(NSArray*)getParcelList{
parcelList = [[NSArray alloc] initWithObjects:@"1x", @"2x", @"3x", @"4x", @"5x", @"6x", @"7x", @"8x",
@"9x", @"10x", @"11x", @"12x", @"13x", @"14x", @"15x",
@"16x", @"17x", @"18x", @"19x", @"20x", @"21x", @"22x",
@"23x", @"24x", nil];
return parcelList;
}
@end