@@ -15,13 +15,11 @@ @interface EVTEventStateProvider ()
1515@property (nonatomic , strong ) EVTEnvironment *environment;
1616@property (nonatomic , strong ) NSURLSession *session;
1717@property (nonatomic , strong ) NSTimer *timer;
18+ @property (nonatomic , assign ) EVTEventState state;
1819
1920@end
2021
2122@implementation EVTEventStateProvider
22- {
23- EVTEventState _state;
24- }
2523
2624- (instancetype )initWithEnvironment : (EVTEnvironment *)environment
2725{
@@ -70,22 +68,25 @@ - (void)__startMonitoring
7068
7169- (void )__stateCheck : (NSTimer *)sender
7270{
71+ __weak typeof (self) weakSelf = self;
72+
7373 [self __fetchStateWithCompletionHandler: ^(NSString *stateName) {
7474 #ifdef DEBUG
7575 NSLog (@" STATE = %@ " , stateName);
7676 #endif
7777 [self willChangeValueForKey: @" state" ];
7878 if ([stateName isEqualToString: @" PRE" ]) {
79- _state = EVTEventStatePre;
79+ weakSelf. state = EVTEventStatePre;
8080 } else if ([stateName isEqualToString: @" LIVE" ]) {
81- _state = EVTEventStateLive;
81+ weakSelf. state = EVTEventStateLive;
8282 } else if ([stateName isEqualToString: @" INTERIM" ]) {
83- _state = EVTEventStateInterim;
83+ weakSelf. state = EVTEventStateInterim;
8484 } else if ([stateName isEqualToString: @" POST" ]) {
85- _state = EVTEventStatePost;
85+ weakSelf. state = EVTEventStatePost;
8686 } else {
8787 NSLog (@" Unknown event state: %@ " , stateName);
8888 }
89+
8990 [self didChangeValueForKey: @" state" ];
9091 }];
9192}
0 commit comments