@@ -411,28 +411,39 @@ + (void)startWithUserId:(NSString *)userId userAttributes:(NSDictionary *)attrib
411411+ (void )triggerStartIssued
412412{
413413 [LPInternalState sharedState ].issuedStart = YES ;
414- @synchronized ([LPInternalState sharedState ].startIssuedBlocks ) {
415- for (LeanplumStartIssuedBlock block in [LPInternalState sharedState ].startIssuedBlocks .copy ) {
414+ NSMutableArray * startIssuedBlocks = [LPInternalState sharedState ].startIssuedBlocks ;
415+
416+ @synchronized (startIssuedBlocks) {
417+ for (LeanplumStartIssuedBlock block in startIssuedBlocks) {
416418 block ();
417419 }
418- [[LPInternalState sharedState ]. startIssuedBlocks removeAllObjects ];
420+ [startIssuedBlocks removeAllObjects ];
419421 }
420422}
421423
422424+ (void )triggerStartResponse : (BOOL )success
423425{
424426 LP_BEGIN_USER_CODE
425- for (NSInvocation *invocation in [LPInternalState sharedState ].startResponders .copy ) {
426- [invocation setArgument: &success atIndex: 2 ];
427- [invocation invoke ];
427+
428+ NSMutableSet * startResponders = [LPInternalState sharedState ].startResponders ;
429+ NSMutableArray * startBlocks = [LPInternalState sharedState ].startBlocks ;
430+
431+ @synchronized (startResponders) {
432+ for (NSInvocation *invocation in startResponders) {
433+ [invocation setArgument: &success atIndex: 2 ];
434+ [invocation invoke ];
435+ }
436+ [startResponders removeAllObjects ];
428437 }
429438
430- for (LeanplumStartBlock block in [LPInternalState sharedState ].startBlocks .copy ) {
431- block (success);
439+ @synchronized (startBlocks) {
440+ for (LeanplumStartBlock block in startBlocks) {
441+ block (success);
442+ }
443+ [startBlocks removeAllObjects ];
432444 }
445+
433446 LP_END_USER_CODE
434- [[LPInternalState sharedState ].startResponders removeAllObjects ];
435- [[LPInternalState sharedState ].startBlocks removeAllObjects ];
436447}
437448
438449+ (void )triggerVariablesChanged
0 commit comments