Skip to content

Commit ca1a3b6

Browse files
committed
in BranchEvent's contentItems and customData properties, use immutable collections rather than mutable ones
1 parent 3bc6437 commit ca1a3b6

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

Branch-SDK/Branch-SDK/BranchEvent.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ typedef NS_ENUM(NSInteger, BranchEventAdType) {
8585
@property (nonatomic, assign) BranchEventAdType adType;
8686

8787

88-
@property (nonatomic, copy) NSMutableArray<BranchUniversalObject*>*_Nonnull contentItems;
89-
@property (nonatomic, copy) NSMutableDictionary<NSString*, NSString*> *_Nonnull customData;
88+
@property (nonatomic, copy) NSArray<BranchUniversalObject*>*_Nonnull contentItems;
89+
@property (nonatomic, copy) NSDictionary<NSString*, NSString*> *_Nonnull customData;
9090

9191
- (void) logEvent; //!< Logs the event on the Branch server.
9292
- (NSDictionary*_Nonnull) dictionary; //!< Returns a dictionary representation of the event.

Branch-SDK/Branch-SDK/BranchEvent.m

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,8 @@ + (BOOL) supportsSecureCoding {
103103

104104
#pragma mark - BranchEvent
105105

106-
@interface BranchEvent () {
107-
NSMutableDictionary *_customData;
108-
NSMutableArray *_contentItems;
109-
}
106+
@interface BranchEvent ()
110107
@property (nonatomic, strong) NSString* eventName;
111-
112108
@end
113109

114110
@implementation BranchEvent : NSObject
@@ -117,7 +113,8 @@ - (instancetype) initWithName:(NSString *)name {
117113
self = [super init];
118114
if (!self) return self;
119115
_eventName = name;
120-
116+
_contentItems = [NSArray new];
117+
_customData = [NSDictionary new];
121118
_adType = BranchEventAdTypeNone;
122119
return self;
123120
}
@@ -130,7 +127,7 @@ + (instancetype) standardEvent:(BranchStandardEvent)standardEvent
130127
withContentItem:(BranchUniversalObject*)contentItem {
131128
BranchEvent *e = [BranchEvent standardEvent:standardEvent];
132129
if (contentItem) {
133-
e.contentItems = (NSMutableArray*) @[ contentItem ];
130+
e.contentItems = @[ contentItem ];
134131
}
135132
return e;
136133
}
@@ -143,36 +140,11 @@ + (instancetype) customEventWithName:(NSString*)name
143140
contentItem:(BranchUniversalObject*)contentItem {
144141
BranchEvent *e = [BranchEvent customEventWithName:name];
145142
if (contentItem) {
146-
e.contentItems = (NSMutableArray*) @[ contentItem ];
143+
e.contentItems = @[ contentItem ];
147144
}
148145
return e;
149146
}
150147

151-
- (NSMutableDictionary*) customData {
152-
if (!_customData) _customData = [NSMutableDictionary new];
153-
return _customData;
154-
}
155-
156-
- (void) setCustomData:(NSMutableDictionary<NSString *,NSString *> *)userInfo {
157-
_customData = [userInfo mutableCopy];
158-
}
159-
160-
- (NSMutableArray*) contentItems {
161-
if (!_contentItems) _contentItems = [NSMutableArray new];
162-
return _contentItems;
163-
}
164-
165-
- (void) setContentItems:(NSMutableArray<BranchUniversalObject *> *)contentItems {
166-
167-
168-
if ([contentItems isKindOfClass:[BranchUniversalObject class]]) {
169-
_contentItems = [NSMutableArray arrayWithObject:contentItems];
170-
} else
171-
if ([contentItems isKindOfClass:[NSArray class]]) {
172-
_contentItems = [contentItems mutableCopy];
173-
}
174-
}
175-
176148
- (NSString *)jsonStringForAdType:(BranchEventAdType)adType {
177149
switch (adType) {
178150
case BranchEventAdTypeBanner:

0 commit comments

Comments
 (0)