|
6 | 6 | // Copyright (c) 2013 adjust GmbH. All rights reserved. |
7 | 7 | // |
8 | 8 |
|
9 | | -#import "ADJActivityPackage.h" |
10 | 9 | #import "ADJActivityKind.h" |
| 10 | +#import "ADJActivityPackage.h" |
11 | 11 |
|
12 | | -#pragma mark - |
13 | 12 | @implementation ADJActivityPackage |
14 | 13 |
|
15 | | -- (NSString *)description { |
16 | | - return [NSString stringWithFormat:@"%@%@", |
17 | | - [ADJActivityKindUtil activityKindToString:self.activityKind], |
18 | | - self.suffix]; |
19 | | -} |
| 14 | +#pragma mark - Public methods |
20 | 15 |
|
21 | 16 | - (NSString *)extendedString { |
22 | 17 | NSMutableString *builder = [NSMutableString string]; |
| 18 | + |
23 | 19 | [builder appendFormat:@"Path: %@\n", self.path]; |
24 | 20 | [builder appendFormat:@"ClientSdk: %@\n", self.clientSdk]; |
25 | 21 |
|
26 | 22 | if (self.parameters != nil) { |
27 | | - NSArray * sortedKeys = [[self.parameters allKeys] sortedArrayUsingSelector:@selector(localizedStandardCompare:)]; |
| 23 | + NSArray *sortedKeys = [[self.parameters allKeys] sortedArrayUsingSelector:@selector(localizedStandardCompare:)]; |
28 | 24 | NSUInteger keyCount = [sortedKeys count]; |
| 25 | + |
29 | 26 | [builder appendFormat:@"Parameters:"]; |
30 | | - for (int i = 0; i < keyCount; i++) { |
| 27 | + |
| 28 | + for (NSUInteger i = 0; i < keyCount; i++) { |
31 | 29 | NSString *key = (NSString*)[sortedKeys objectAtIndex:i]; |
32 | 30 | NSString *value = [self.parameters objectForKey:key]; |
| 31 | + |
33 | 32 | [builder appendFormat:@"\n\t\t%-22s %@", [key UTF8String], value]; |
34 | 33 | } |
35 | 34 | } |
36 | 35 |
|
37 | 36 | return builder; |
38 | 37 | } |
39 | 38 |
|
40 | | -- (NSString *)successMessage { |
41 | | - return [NSString stringWithFormat:@"Tracked %@%@", |
42 | | - [ADJActivityKindUtil activityKindToString:self.activityKind], |
43 | | - self.suffix]; |
44 | | -} |
45 | | - |
46 | | -- (NSString *)failureMessage { |
47 | | - return [NSString stringWithFormat:@"Failed to track %@%@", |
48 | | - [ADJActivityKindUtil activityKindToString:self.activityKind], |
49 | | - self.suffix]; |
50 | | -} |
51 | | - |
52 | 39 | - (NSInteger)getRetries { |
53 | 40 | return self.retries; |
54 | 41 | } |
55 | 42 |
|
56 | 43 | - (NSInteger)increaseRetries { |
57 | 44 | self.retries = self.retries + 1; |
| 45 | + |
58 | 46 | return self.retries; |
59 | 47 | } |
60 | 48 |
|
61 | | -#pragma mark NSCoding |
| 49 | +- (NSString *)description { |
| 50 | + return [NSString stringWithFormat:@"%@%@", [ADJActivityKindUtil activityKindToString:self.activityKind], self.suffix]; |
| 51 | +} |
| 52 | + |
| 53 | +- (NSString *)successMessage { |
| 54 | + return [NSString stringWithFormat:@"Tracked %@%@", [ADJActivityKindUtil activityKindToString:self.activityKind], self.suffix]; |
| 55 | +} |
| 56 | + |
| 57 | +- (NSString *)failureMessage { |
| 58 | + return [NSString stringWithFormat:@"Failed to track %@%@", [ADJActivityKindUtil activityKindToString:self.activityKind], self.suffix]; |
| 59 | +} |
| 60 | + |
| 61 | +#pragma mark - NSCoding protocol methods |
| 62 | + |
62 | 63 | - (id)initWithCoder:(NSCoder *)decoder { |
63 | 64 | self = [super init]; |
64 | | - if (self == nil) return self; |
| 65 | + |
| 66 | + if (self == nil) { |
| 67 | + return self; |
| 68 | + } |
65 | 69 |
|
66 | 70 | self.path = [decoder decodeObjectForKey:@"path"]; |
| 71 | + self.suffix = [decoder decodeObjectForKey:@"suffix"]; |
67 | 72 | self.clientSdk = [decoder decodeObjectForKey:@"clientSdk"]; |
68 | 73 | self.parameters = [decoder decodeObjectForKey:@"parameters"]; |
69 | | - NSString *kindString = [decoder decodeObjectForKey:@"kind"]; |
70 | | - self.suffix = [decoder decodeObjectForKey:@"suffix"]; |
| 74 | + self.partnerParameters = [decoder decodeObjectForKey:@"partnerParameters"]; |
| 75 | + self.callbackParameters = [decoder decodeObjectForKey:@"callbackParameters"]; |
71 | 76 |
|
| 77 | + NSString *kindString = [decoder decodeObjectForKey:@"kind"]; |
72 | 78 | self.activityKind = [ADJActivityKindUtil activityKindFromString:kindString]; |
73 | 79 |
|
74 | | - self.callbackParameters = [decoder decodeObjectForKey:@"callbackParameters"]; |
75 | | - self.partnerParameters = [decoder decodeObjectForKey:@"partnerParameters"]; |
76 | 80 | return self; |
77 | 81 | } |
78 | 82 |
|
79 | 83 | - (void)encodeWithCoder:(NSCoder *)encoder { |
80 | 84 | NSString *kindString = [ADJActivityKindUtil activityKindToString:self.activityKind]; |
81 | 85 |
|
82 | 86 | [encoder encodeObject:self.path forKey:@"path"]; |
83 | | - [encoder encodeObject:self.clientSdk forKey:@"clientSdk"]; |
84 | | - [encoder encodeObject:self.parameters forKey:@"parameters"]; |
85 | 87 | [encoder encodeObject:kindString forKey:@"kind"]; |
86 | 88 | [encoder encodeObject:self.suffix forKey:@"suffix"]; |
| 89 | + [encoder encodeObject:self.clientSdk forKey:@"clientSdk"]; |
| 90 | + [encoder encodeObject:self.parameters forKey:@"parameters"]; |
87 | 91 | [encoder encodeObject:self.callbackParameters forKey:@"callbackParameters"]; |
88 | 92 | [encoder encodeObject:self.partnerParameters forKey:@"partnerParameters"]; |
89 | 93 | } |
|
0 commit comments