diff --git a/iOS/GBROMViewController.m b/iOS/GBROMViewController.m index bb6b1e81d..e6d386466 100644 --- a/iOS/GBROMViewController.m +++ b/iOS/GBROMViewController.m @@ -8,6 +8,7 @@ @implementation GBROMViewController { NSIndexPath *_renamingPath; + NSArray *_roms; } - (instancetype)init @@ -20,6 +21,11 @@ - (instancetype)init name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self.tableView + selector:@selector(reloadData) + name:UIApplicationDidBecomeActiveNotification + object:nil]; + return self; } @@ -31,7 +37,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 1) return 2; - return [GBROMManager sharedManager].allROMs.count; + return (_roms = [GBROMManager sharedManager].allROMs).count; } - (UITableViewCell *)cellForROM:(NSString *)rom @@ -72,7 +78,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } return cell; } - return [self cellForROM:[GBROMManager sharedManager].allROMs[[indexPath indexAtPosition:1]]]; + return [self cellForROM:_roms[[indexPath indexAtPosition:1]]]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath @@ -96,7 +102,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte - (void)romSelectedAtIndex:(unsigned)index { - NSString *rom = [GBROMManager sharedManager].allROMs[index]; + NSString *rom = _roms[index]; [GBROMManager sharedManager].currentROM = rom; [self.presentingViewController dismissViewControllerAnimated:true completion:nil]; } @@ -178,7 +184,7 @@ - (UIModalPresentationStyle)modalPresentationStyle - (void)deleteROMAtIndex:(unsigned)index { - NSString *rom = [GBROMManager sharedManager].allROMs[index]; + NSString *rom = _roms[index]; [[GBROMManager sharedManager] deleteROM:rom]; [self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic]; @@ -265,7 +271,7 @@ - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *) - (void)duplicateROMAtIndex:(unsigned)index { - [[GBROMManager sharedManager] duplicateROM:[GBROMManager sharedManager].allROMs[index]]; + [[GBROMManager sharedManager] duplicateROM:_roms[index]]; [self.tableView reloadData]; }