Skip to content

Instantly share code, notes, and snippets.

@lamprosg
Last active December 15, 2015 04:39
Show Gist options
  • Select an option

  • Save lamprosg/5202874 to your computer and use it in GitHub Desktop.

Select an option

Save lamprosg/5202874 to your computer and use it in GitHub Desktop.
(iOS) Backwards iteration. Check a property of a previous controller in the navigation hierarchy
//Example
//Pop views and return to mapresultsviewcontroller
for(UIViewController *vc in [self.navigationController viewControllers]) {
//MapAreaRsultsViewController is 2 controllers back in the hierarchy
if([vc isMemberOfClass:[MapAreaResultsViewController class]]) {
//Remove record from memory
NSMutableArray *records;
if (((MapAreaResultsViewController *)vc).resultsType == HOME_PAGE) {
records = [[NSMutableArray alloc] initWithArray:Eng.search.resultsHome];
} else if (((MapAreaResultsViewController *)vc).resultsType == PROFILE_PAGE) {
records = [[NSMutableArray alloc] initWithArray:Eng.search.resultsProfile];
} else {
records = [[NSMutableArray alloc] initWithArray:Eng.search.resultsSearch];
}
[records removeObject:Eng.details.record];
[((MapAreaResultsViewController *)vc) reloadViewData];
[self.navigationController popToViewController:vc animated:YES];
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment