From acbdfb776dd31778bed4b7e67865ebe5a2370e8d Mon Sep 17 00:00:00 2001 From: Alex Pawlowski Date: Wed, 22 Feb 2017 14:23:38 +0200 Subject: [PATCH] Dispatch LOTAnimationView completion to the main thread on macOS (fixes #103) --- lottie-ios/Classes/Private/LOTAnimationView.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lottie-ios/Classes/Private/LOTAnimationView.m b/lottie-ios/Classes/Private/LOTAnimationView.m index 9e7fc76984..a9dd38aaa8 100644 --- a/lottie-ios/Classes/Private/LOTAnimationView.m +++ b/lottie-ios/Classes/Private/LOTAnimationView.m @@ -557,6 +557,17 @@ - (void)layoutSubviews { } #else + +- (void)setCompletionBlock:(LOTAnimationCompletionBlock)completionBlock { + if (completionBlock) { + _completionBlock = ^(BOOL finished) { + dispatch_async(dispatch_get_main_queue(), ^{ completionBlock(finished); }); + }; + } + else { + _completionBlock = nil; + } +} - (void)setContentMode:(LOTViewContentMode)contentMode { _contentMode = contentMode;