Hi All,
Just wondering where on earth I should release cdvController...
Everywhere I release it seems to be fine when I push it, but crash the app when I pop back.
Code:
-(void)loadCellPress {
//show loading symbol
// Should be initialized with the windows frame so the HUD disables all user input by covering the entire screen
HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
// Add HUD to screen
[self.parentViewController.view addSubview:HUD];
// Regisete for HUD callbacks so we can remove it from the window at the right time
HUD.delegate = self;
// Show the HUD while the provided method executes in a new thread
[HUD showWhileExecuting:@selector(cellPress) onTarget:self withObject:nil animated:YES];
}
- (void)cellPress {
activeSegment = toggle.selectedSegmentIndex;
if(cdvController == nil) {
cdvController = [[CafeDetailViewController alloc] initWithNibName:@"CafeDetailViewController" bundle:[NSBundle mainBundle]];
}
switch (self.tabBarController.selectedIndex) {
case 0:
cdvController.aCafe = [cafesSearch objectAtIndex:whichRow];
break;
case 1:
cdvController.aCafe = [cafesNearMe objectAtIndex:whichRow];
break;
case 3:
cdvController.aCafe = [cafesFavourites objectAtIndex:whichRow];
break;
default:
break;
}
[self performSelectorOnMainThread:@selector(pushVC:) withObject:cdvController waitUntilDone:NO];
}
- (void)pushVC:(UIViewController *)whichView {
[self.navigationController pushViewController:whichView animated:YES];
}