|
8 | 8 |
|
9 | 9 | @implementation CountlyEvent |
10 | 10 |
|
11 | | -NSString *const kCountlyEventKeyKey = @"key"; |
12 | | -NSString *const kCountlyEventKeyID = @"id"; |
13 | | -NSString *const kCountlyEventKeyCVID = @"cvid"; |
14 | | -NSString *const kCountlyEventKeyPVID = @"pvid"; |
15 | | -NSString *const kCountlyEventKeyPEID = @"peid"; |
16 | | -NSString *const kCountlyEventKeySegmentation = @"segmentation"; |
17 | | -NSString *const kCountlyEventKeyCount = @"count"; |
18 | | -NSString *const kCountlyEventKeySum = @"sum"; |
19 | | -NSString *const kCountlyEventKeyTimestamp = @"timestamp"; |
20 | | -NSString *const kCountlyEventKeyHourOfDay = @"hour"; |
21 | | -NSString *const kCountlyEventKeyDayOfWeek = @"dow"; |
22 | | -NSString *const kCountlyEventKeyDuration = @"dur"; |
| 11 | +NSString* const kCountlyEventKeyKey = @"key"; |
| 12 | +NSString* const kCountlyEventKeyID = @"id"; |
| 13 | +NSString* const kCountlyEventKeyCVID = @"cvid"; |
| 14 | +NSString* const kCountlyEventKeyPVID = @"pvid"; |
| 15 | +NSString* const kCountlyEventKeyPEID = @"peid"; |
| 16 | +NSString* const kCountlyEventKeySegmentation = @"segmentation"; |
| 17 | +NSString* const kCountlyEventKeyCount = @"count"; |
| 18 | +NSString* const kCountlyEventKeySum = @"sum"; |
| 19 | +NSString* const kCountlyEventKeyTimestamp = @"timestamp"; |
| 20 | +NSString* const kCountlyEventKeyHourOfDay = @"hour"; |
| 21 | +NSString* const kCountlyEventKeyDayOfWeek = @"dow"; |
| 22 | +NSString* const kCountlyEventKeyDuration = @"dur"; |
23 | 23 |
|
24 | | -/** |
25 | | - * This function is a critical component used within the `CountlyPersistency.serializeRecordedEvents` method. |
26 | | - * |
27 | | - * Note: If this function is modified, ensure that corresponding updates are made to |
28 | | - * the `CountlyPersistency.serializeRecordedEvents` method to maintain consistency and prevent potential issues. |
29 | | - * |
30 | | - * @warning Changes to this function may have downstream effects. Proceed with caution. |
31 | | - */ |
| 24 | +/** |
| 25 | +* This function is a critical component used within the `CountlyPersistency.serializeRecordedEvents` method. |
| 26 | +* |
| 27 | +* Note: If this function is modified, ensure that corresponding updates are made to |
| 28 | +* the `CountlyPersistency.serializeRecordedEvents` method to maintain consistency and prevent potential issues. |
| 29 | +* |
| 30 | +* @warning Changes to this function may have downstream effects. Proceed with caution. |
| 31 | +*/ |
32 | 32 | - (NSDictionary *)dictionaryRepresentation |
33 | 33 | { |
34 | | - NSMutableDictionary *eventData = NSMutableDictionary.dictionary; |
35 | | - eventData[kCountlyEventKeyKey] = self.key; |
36 | | - if (self.segmentation) |
37 | | - { |
38 | | - eventData[kCountlyEventKeySegmentation] = self.segmentation; |
39 | | - } |
40 | | - eventData[kCountlyEventKeyID] = self.ID; |
41 | | - eventData[kCountlyEventKeyCVID] = self.CVID; |
42 | | - eventData[kCountlyEventKeyPVID] = self.PVID; |
43 | | - eventData[kCountlyEventKeyPEID] = self.PEID; |
44 | | - eventData[kCountlyEventKeyCount] = @(self.count); |
45 | | - eventData[kCountlyEventKeySum] = @(self.sum); |
46 | | - eventData[kCountlyEventKeyTimestamp] = @((long long)(self.timestamp * 1000)); |
47 | | - eventData[kCountlyEventKeyHourOfDay] = @(self.hourOfDay); |
48 | | - eventData[kCountlyEventKeyDayOfWeek] = @(self.dayOfWeek); |
49 | | - eventData[kCountlyEventKeyDuration] = @(self.duration); |
50 | | - return eventData; |
| 34 | + NSMutableDictionary* eventData = NSMutableDictionary.dictionary; |
| 35 | + eventData[kCountlyEventKeyKey] = self.key; |
| 36 | + if (self.segmentation) |
| 37 | + { |
| 38 | + eventData[kCountlyEventKeySegmentation] = self.segmentation; |
| 39 | + } |
| 40 | + eventData[kCountlyEventKeyID] = self.ID; |
| 41 | + eventData[kCountlyEventKeyCVID] = self.CVID; |
| 42 | + eventData[kCountlyEventKeyPVID] = self.PVID; |
| 43 | + eventData[kCountlyEventKeyPEID] = self.PEID; |
| 44 | + eventData[kCountlyEventKeyCount] = @(self.count); |
| 45 | + eventData[kCountlyEventKeySum] = @(self.sum); |
| 46 | + eventData[kCountlyEventKeyTimestamp] = @((long long)(self.timestamp * 1000)); |
| 47 | + eventData[kCountlyEventKeyHourOfDay] = @(self.hourOfDay); |
| 48 | + eventData[kCountlyEventKeyDayOfWeek] = @(self.dayOfWeek); |
| 49 | + eventData[kCountlyEventKeyDuration] = @(self.duration); |
| 50 | + return eventData; |
51 | 51 | } |
52 | 52 |
|
53 | 53 | - (instancetype)initWithCoder:(NSCoder *)decoder |
54 | 54 | { |
55 | | - if (self = [super init]) |
56 | | - { |
57 | | - self.key = [decoder decodeObjectForKey:NSStringFromSelector(@selector(key))]; |
58 | | - self.ID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(ID))]; |
59 | | - self.CVID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(CVID))]; |
60 | | - self.PVID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(PVID))]; |
61 | | - self.PEID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(PEID))]; |
62 | | - self.segmentation = [decoder decodeObjectForKey:NSStringFromSelector(@selector(segmentation))]; |
63 | | - self.count = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(count))]; |
64 | | - self.sum = [decoder decodeDoubleForKey:NSStringFromSelector(@selector(sum))]; |
65 | | - self.timestamp = [decoder decodeDoubleForKey:NSStringFromSelector(@selector(timestamp))]; |
66 | | - self.hourOfDay = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(hourOfDay))]; |
67 | | - self.dayOfWeek = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(dayOfWeek))]; |
68 | | - self.duration = [decoder decodeDoubleForKey:NSStringFromSelector(@selector(duration))]; |
69 | | - } |
70 | | - |
71 | | - return self; |
| 55 | + if (self = [super init]) |
| 56 | + { |
| 57 | + self.key = [decoder decodeObjectForKey:NSStringFromSelector(@selector(key))]; |
| 58 | + self.ID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(ID))]; |
| 59 | + self.CVID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(CVID))]; |
| 60 | + self.PVID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(PVID))]; |
| 61 | + self.PEID = [decoder decodeObjectForKey:NSStringFromSelector(@selector(PEID))]; |
| 62 | + self.segmentation = [decoder decodeObjectForKey:NSStringFromSelector(@selector(segmentation))]; |
| 63 | + self.count = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(count))]; |
| 64 | + self.sum = [decoder decodeDoubleForKey:NSStringFromSelector(@selector(sum))]; |
| 65 | + self.timestamp = [decoder decodeDoubleForKey:NSStringFromSelector(@selector(timestamp))]; |
| 66 | + self.hourOfDay = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(hourOfDay))]; |
| 67 | + self.dayOfWeek = [decoder decodeIntegerForKey:NSStringFromSelector(@selector(dayOfWeek))]; |
| 68 | + self.duration = [decoder decodeDoubleForKey:NSStringFromSelector(@selector(duration))]; |
| 69 | + } |
| 70 | + |
| 71 | + return self; |
72 | 72 | } |
73 | 73 |
|
74 | 74 | - (void)encodeWithCoder:(NSCoder *)encoder |
75 | 75 | { |
76 | | - [encoder encodeObject:self.key forKey:NSStringFromSelector(@selector(key))]; |
77 | | - [encoder encodeObject:self.ID forKey:NSStringFromSelector(@selector(ID))]; |
78 | | - [encoder encodeObject:self.CVID forKey:NSStringFromSelector(@selector(CVID))]; |
79 | | - [encoder encodeObject:self.PVID forKey:NSStringFromSelector(@selector(PVID))]; |
80 | | - [encoder encodeObject:self.PEID forKey:NSStringFromSelector(@selector(PEID))]; |
81 | | - [encoder encodeObject:self.segmentation forKey:NSStringFromSelector(@selector(segmentation))]; |
82 | | - [encoder encodeInteger:self.count forKey:NSStringFromSelector(@selector(count))]; |
83 | | - [encoder encodeDouble:self.sum forKey:NSStringFromSelector(@selector(sum))]; |
84 | | - [encoder encodeDouble:self.timestamp forKey:NSStringFromSelector(@selector(timestamp))]; |
85 | | - [encoder encodeInteger:self.hourOfDay forKey:NSStringFromSelector(@selector(hourOfDay))]; |
86 | | - [encoder encodeInteger:self.dayOfWeek forKey:NSStringFromSelector(@selector(dayOfWeek))]; |
87 | | - [encoder encodeDouble:self.duration forKey:NSStringFromSelector(@selector(duration))]; |
| 76 | + [encoder encodeObject:self.key forKey:NSStringFromSelector(@selector(key))]; |
| 77 | + [encoder encodeObject:self.ID forKey:NSStringFromSelector(@selector(ID))]; |
| 78 | + [encoder encodeObject:self.CVID forKey:NSStringFromSelector(@selector(CVID))]; |
| 79 | + [encoder encodeObject:self.PVID forKey:NSStringFromSelector(@selector(PVID))]; |
| 80 | + [encoder encodeObject:self.PEID forKey:NSStringFromSelector(@selector(PEID))]; |
| 81 | + [encoder encodeObject:self.segmentation forKey:NSStringFromSelector(@selector(segmentation))]; |
| 82 | + [encoder encodeInteger:self.count forKey:NSStringFromSelector(@selector(count))]; |
| 83 | + [encoder encodeDouble:self.sum forKey:NSStringFromSelector(@selector(sum))]; |
| 84 | + [encoder encodeDouble:self.timestamp forKey:NSStringFromSelector(@selector(timestamp))]; |
| 85 | + [encoder encodeInteger:self.hourOfDay forKey:NSStringFromSelector(@selector(hourOfDay))]; |
| 86 | + [encoder encodeInteger:self.dayOfWeek forKey:NSStringFromSelector(@selector(dayOfWeek))]; |
| 87 | + [encoder encodeDouble:self.duration forKey:NSStringFromSelector(@selector(duration))]; |
88 | 88 | } |
89 | 89 | @end |
0 commit comments