I am trying to update a label on view controller (DropPinVC) by pressing a button on different view controller 2 (TypeLocation).
In DropPinVC.m I have:
- (void)viewDidLoad
{
TypeLocation *VC2 = [[TypeLocation alloc] initWithNibName:@"TypeLocation" bundle:nil];
VC2.myVC2 = self;
[super viewDidLoad];
}
In TypeLocation.h I have:
@property (nonatomic, strong) DropPinVC *myVC2;
In TypeLocation.m I have:
-(IBAction) switchValueChanged
{
if (self.TASwitch.on){
TypeLocation = @"Tourist Attraction";
[[NSUserDefaults standardUserDefaults] setObject:TypeLocation forKey:@"Type Location"];
}
else {
TypeLocation = @"Unsafe Location";
[[NSUserDefaults standardUserDefaults] setObject:TypeLocation forKey:@"Type Location"];
DropPinVC *myVC2 = [[DropPinVC alloc] initWithNibName:@"DropPinVC" bundle:nil];
NSString *updatedLabel = [[NSUserDefaults standardUserDefaults] stringForKey:@"Type Location"];
NSLog(@"Updated Label = %@", updatedLabel);
myVC2.TypeLabel.text = updatedLabel;
[self closeScreen];
}
However, the label on view controller 1 does not update. Does anybody know a solution to this problem? Thank you for your help!