+ [ios] update timer
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/7deda59f Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/7deda59f Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/7deda59f Branch: refs/heads/0.16-dev Commit: 7deda59fd59d6480b43c3fc280c820f67b1c75aa Parents: 46e6f3d Author: é½å±± <[email protected]> Authored: Thu Sep 21 14:47:22 2017 +0800 Committer: é½å±± <[email protected]> Committed: Thu Sep 21 14:47:22 2017 +0800 ---------------------------------------------------------------------- ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7deda59f/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m index f974a0e..fb07935 100644 --- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m +++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m @@ -492,13 +492,14 @@ [_timers addObject:ret]; [self addInstance:appId callback:ret]; } + __weak typeof(self) weakSelf = self; dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, interval*NSEC_PER_SEC); dispatch_after(time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSMutableDictionary *dic = [NSMutableDictionary new]; [dic setObject:appId forKey:@"appId"]; [dic setObject:ret forKey:@"ret"]; [dic setObject:arg forKey:@"arg"]; - [self performSelector:@selector(callBack:) withObject:dic ]; + [weakSelf performSelector:@selector(callBack:) withObject:dic ]; }); } @@ -526,12 +527,13 @@ { double interval = [arg doubleValue]/1000.0f; dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, interval*NSEC_PER_SEC); + __weak typeof(self) weakSelf = self; dispatch_after(time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSMutableDictionary *dic = [NSMutableDictionary new]; [dic setObject:appId forKey:@"appId"]; [dic setObject:arg forKey:@"arg"]; [dic setObject:@(timerId) forKey:@"timerId"]; - [self performSelector:@selector(callBackInterval:functon:) withObject:dic withObject:block]; + [weakSelf performSelector:@selector(callBackInterval:functon:) withObject:dic withObject:block]; }); }
