From 6b16861002d660cb25e167ca34020dd32bbe222c Mon Sep 17 00:00:00 2001 From: Nick Lin Date: Sat, 7 Apr 2018 20:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=91=BC=E5=8F=AB=20Delegate?= =?UTF-8?q?=20=E6=99=82=20=E4=BD=BF=E7=94=A8=20Main=20Thread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModelMultipleContentDataProtocol.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MVVM/Base/Protocol/ViewModelMultipleContentDataProtocol.swift b/MVVM/Base/Protocol/ViewModelMultipleContentDataProtocol.swift index 44a1339..c132492 100644 --- a/MVVM/Base/Protocol/ViewModelMultipleContentDataProtocol.swift +++ b/MVVM/Base/Protocol/ViewModelMultipleContentDataProtocol.swift @@ -56,7 +56,9 @@ extension ViewModelLoadingProtocol where Self: ViewModelMultipleContentDataProto case .initialize, .loadFail: status = .loadStart if models.isEmpty { - loadingStatusDelegate?.showLoading(true) + DispatchQueue.main.async { + self.loadingStatusDelegate?.showLoading(true) + } } loadData() @@ -66,8 +68,11 @@ extension ViewModelLoadingProtocol where Self: ViewModelMultipleContentDataProto case .refreshLoading: status = .loadStart - models = [] - loadingStatusDelegate?.showLoading(true) + if models.isEmpty { + DispatchQueue.main.async { + self.loadingStatusDelegate?.showLoading(true) + } + } loadData() case .loadStart, .loadMoreStart, .noMoreCanLoad: