I have seen many many answers about this but for some reason it is not working for me. I have a property in file A, then in file B I set the variable to some value an on the viewdidappear on file A I /Run some code" based on what the variable was assigned to.
So. this is my code. (bare minimal) ViewController.H
@property(strong, nonatomic) NSString *option;
ViewController.M
-(void)viewDidAppear:(BOOL)animated
{
NSLog(@"Has apeparsed");
if ([_option isEqualToString:@"1"]) {
[_map removeAnnotation:budAnno];
}
}
ViewControllerB.h
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[recipes objectAtIndex:indexPath.row] isEqualToString:@"TEST"])
{
ViewController *viewO =[[ViewController alloc]init];
viewO.option=@"1";
}
}
when this code is called in ViewControllerB Options is set to 1. but when I click BACK to viewContoller.M my if statement fails because it is back to nil. would like to know why this is done.