-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrequencyDb.m
More file actions
39 lines (24 loc) · 748 Bytes
/
FrequencyDb.m
File metadata and controls
39 lines (24 loc) · 748 Bytes
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
//
// FrequencyDb.m
//
// Licensed by ruralcoder.com under the
// Creative Commons Attribution-ShareAlike 3.0 Unported License
#import "FrequencyDb.h"
#import "NSDictionaryExtension.h"
@implementation FrequencyDb
- (void) increaseUse:(id)key
{
NSUInteger freqValue = 1;
NSNumber *frequency = [self.fields objectForKey:key];
if (frequency)
freqValue = [frequency unsignedIntegerValue] + 1;
frequency = [NSNumber numberWithUnsignedInteger:freqValue];
[self addObject:frequency forKey:key overwrite:YES];
}
- (NSUInteger) frequencyForKey:(id)key
{
if ([self.fields containsKey:key] == NO)
return 0;
return [[self.fields objectForKey:key] unsignedIntegerValue];
}
@end