From a405e1f752e0db251cf1a5bed79c74b2b79a8e89 Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Sat, 8 Jun 2024 00:11:33 +0900 Subject: [PATCH] Update MTBReportViewModel.m --- Source/MTBReportViewModel.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/MTBReportViewModel.m b/Source/MTBReportViewModel.m index e3be03e..197bfb5 100644 --- a/Source/MTBReportViewModel.m +++ b/Source/MTBReportViewModel.m @@ -37,10 +37,10 @@ - (void)getTrackersWithSuccess:(void (^)(NSArray *reports, NSString *m __weak typeof(self) weakSelf = self; [managedObjectContext performBlock:^{ __strong typeof(self) strongSelf = weakSelf; - [strongSelf.managedObjectContext refreshAllObjects]; + [weakSelf.managedObjectContext refreshAllObjects]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Tracker" - inManagedObjectContext:[self managedObjectContext]]; + inManagedObjectContext:[strongSelf managedObjectContext]]; [fetchRequest setEntity:entity]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; @@ -50,7 +50,7 @@ - (void)getTrackersWithSuccess:(void (^)(NSArray *reports, NSString *m NSError *error = nil; - strongSelf.reports = [strongSelf.managedObjectContext executeFetchRequest:fetchRequest error:&error]; + weakSelf.reports = [strongSelf.managedObjectContext executeFetchRequest:fetchRequest error:&error]; NSString *mostFreqTrackerName = @""; NSUInteger maxTrackerCount = 0; @@ -76,7 +76,7 @@ - (void)getTrackerRatioWithSuccess:(void (^)(NSString *percentage))successComple __strong typeof(self) strongSelf = weakSelf; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Email" - inManagedObjectContext:[self managedObjectContext]]; + inManagedObjectContext:[strongSelf managedObjectContext]]; [fetchRequest setEntity:entity]; NSError *error = nil; @@ -99,9 +99,9 @@ - (void)getTrackerRatioWithSuccess:(void (^)(NSString *percentage))successComple -(NSInteger)numberOfChildrenOfItem:(id)item { if (!item) { - return _reports.count; + return _reports.count; // # of trackers } - return ((Tracker *)item).reports.count; + return ((Tracker *)item).reports.count; // seen instances of a given tracker } -(id)modelAtChild:(NSInteger)index ofItem:(id)item {