forked from twobitlabs/AnalyticsKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyticsKitEvent.m
More file actions
46 lines (38 loc) · 1.13 KB
/
AnalyticsKitEvent.m
File metadata and controls
46 lines (38 loc) · 1.13 KB
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
//
// AnalyticsKitEvent.m
// TeamStream
//
// Created by Todd Huss on 11/14/12.
// Copyright (c) 2012 Two Bit Labs. All rights reserved.
//
#import "AnalyticsKitEvent.h"
@implementation AnalyticsKitEvent
- (instancetype)initEvent:(NSString *)event {
return [self initEvent:event withProperties:nil];
}
- (instancetype)initEvent:(NSString *)event withProperties:(NSDictionary *)dict {
self = [super init];
if (self) {
self.name = event;
self.properties = dict;
}
return self;
}
- (instancetype)initEvent:(NSString *)event withKey:(NSString *)key andValue:(NSString *)value {
self = [super init];
if (self) {
self.name = event;
if ([key conformsToProtocol:@protocol(NSCopying)] && value != nil) {
self.properties = @{key : value};
}
}
return self;
}
- (void)setProperty:(id)value forKey:(NSString *)key {
if ([key conformsToProtocol:@protocol(NSCopying)] && value != nil) {
NSMutableDictionary *properties = [@{key:value} mutableCopy];
[properties addEntriesFromDictionary:self.properties];
self.properties = properties;
}
}
@end