@@ -30,30 +30,31 @@ @implementation NRMASAM {
30
30
- (id )initWithAttributeValidator : (__nullable id <AttributeValidatorProtocol>)validator {
31
31
self = [super init ];
32
32
if (self) {
33
+ attributeValidator = validator;
34
+
33
35
_attributePersistentStore = [[PersistentEventStore alloc ] initWithFilename: [NRMASAM attributeFilePath ] andMinimumDelay: .025 ];
34
36
35
37
_privateAttributePersistentStore = [[PersistentEventStore alloc ] initWithFilename: [NRMASAM privateAttributeFilePath ] andMinimumDelay: .025 ];
36
38
37
39
// Load public attributes from file.
38
40
NSDictionary *lastSessionAttributes = [PersistentEventStore getLastSessionEventsFromFilename: [NRMASAM attributeFilePath ]];
41
+ attributeDict = [[NSMutableDictionary alloc ] init ];
39
42
if (lastSessionAttributes != nil ) {
40
- attributeDict = [lastSessionAttributes mutableCopy ];
41
- }
42
- if (!attributeDict) {
43
- attributeDict = [[NSMutableDictionary alloc ] init ];
43
+ for (NSString * key in [lastSessionAttributes allKeys ]) {
44
+ [self setAttribute: key value: [lastSessionAttributes valueForKey: key]];
45
+ }
44
46
}
45
47
46
48
// Load private attributes from file.
47
49
NSDictionary *lastSessionPrivateAttributes = [PersistentEventStore getLastSessionEventsFromFilename: [NRMASAM privateAttributeFilePath ]];
48
-
50
+ privateAttributeDict = [[NSMutableDictionary alloc ] init ];
51
+
49
52
if (lastSessionPrivateAttributes != nil ) {
50
- privateAttributeDict = [lastSessionPrivateAttributes mutableCopy ];
51
- }
52
- if (!privateAttributeDict) {
53
- privateAttributeDict = [[NSMutableDictionary alloc ] init ];
53
+ for (NSString * key in [lastSessionPrivateAttributes allKeys ]) {
54
+ [self setNRSessionAttribute: key value: [lastSessionPrivateAttributes valueForKey: key]];
55
+ }
54
56
}
55
-
56
- attributeValidator = validator;
57
+
57
58
}
58
59
return self;
59
60
}
0 commit comments