Skip to content

Commit

Permalink
Fixed crash when changing inventory filters on iPad
Browse files Browse the repository at this point in the history
  • Loading branch information
koraktor committed May 14, 2015
1 parent 3e43d29 commit d5bbc15
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Suitcase/Classes/SCGamesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,27 @@ - (void)settingsChanged:(NSNotification *)notification {
}
}];

self.inventories = [newInventories sortedArrayUsingSelector:@selector(compare:)];

if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)];
[self.tableView beginUpdates];
[self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationTop];
BOOL inventoriesEmptyBefore = [self.inventories count] == 0;
self.inventories = [newInventories sortedArrayUsingSelector:@selector(compare:)];
BOOL inventoriesEmptyAfter = [self.inventories count] == 0;
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)]
withRowAnimation:UITableViewRowAnimationFade];
NSIndexSet *gamesSection = [NSIndexSet indexSetWithIndex:SCInventorySectionGames];
if (inventoriesEmptyBefore != inventoriesEmptyAfter) {
if (inventoriesEmptyAfter) {
[self.tableView insertSections:gamesSection withRowAnimation:UITableViewRowAnimationFade];
} else {
[self.tableView deleteSections:gamesSection withRowAnimation:UITableViewRowAnimationFade];
}
} else {
[self.tableView reloadSections:gamesSection withRowAnimation:UITableViewRowAnimationFade];
}

[self.tableView endUpdates];
} else {
self.inventories = [newInventories sortedArrayUsingSelector:@selector(compare:)];
[self.tableView reloadData];
}
}
Expand Down

0 comments on commit d5bbc15

Please sign in to comment.