From bd2f325ccf7a029b708bab420e44b40c9df51941 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 11 Oct 2022 09:49:40 +1300 Subject: [PATCH] Use `Blog` instance's context to access its properties --- .../WeeklyRoundupBackgroundTask.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift b/WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift index a7a94100f4c4..20b6c45be663 100644 --- a/WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift +++ b/WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift @@ -537,10 +537,15 @@ class WeeklyRoundupNotificationScheduler { comments: Int, likes: Int, periodEndDate: Date, - completion: @escaping (Result) -> Void) { - - let siteTitle = site.title - let dotComID = site.dotComID?.intValue + completion: @escaping (Result) -> Void + ) { + var siteTitle: String? + var dotComID: Int? + + site.managedObjectContext?.performAndWait { + siteTitle = site.title + dotComID = site.dotComID?.intValue + } guard let dotComID = dotComID else { // Error