From be57b417328877915073435b2bad0db25efe331e Mon Sep 17 00:00:00 2001 From: zhanglong15 Date: Mon, 18 Mar 2024 16:51:09 +0800 Subject: [PATCH] =?UTF-8?q?MJRefreshDispatchAsyncOnMainQueue=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=BB=E7=BA=BF=E7=A8=8B=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MJRefresh/MJRefreshConst.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MJRefresh/MJRefreshConst.h b/MJRefresh/MJRefreshConst.h index 6881115c..fe2ee157 100644 --- a/MJRefresh/MJRefreshConst.h +++ b/MJRefresh/MJRefreshConst.h @@ -75,11 +75,15 @@ if (state == oldState) return; \ // 异步主线程执行,不强持有Self #define MJRefreshDispatchAsyncOnMainQueue(x) \ +if (NSThread.isMainThread) { \ +{x} \ +} else { \ __weak typeof(self) weakSelf = self; \ dispatch_async(dispatch_get_main_queue(), ^{ \ typeof(weakSelf) self = weakSelf; \ {x} \ -}); +}); \ +} /// 替换方法实现 /// @param _fromClass 源类