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 {