I know this question was asked about a 100 times but I just can't figure out what I'm doing wrong.
This ist my second iOS App. I want to modify a Label in my ViewControllerB by pressing a Button in my ViewControllerA.
- I made a Segue in Storyboard from my Button (
ViewControllerA
) to myViewControllerB
and called it "TestSegue". - Wrote
#import "ViewControllerB.h
in myViewControllerA.h
- I wrote this Code in my ViewControllerA.m :
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"TestSegue"]){
ViewControllerB *controller = (ViewControllerB *)segue.destinationViewController;
controller.TestLabel.text = @"TEST!";}}
In my ViewControllerB nothing happens with the TestLabel...
Can anybody see what I did wrong?
Thanks in advance
Edit: Works now thanks to rpledge.
New Code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if([segue.identifier isEqualToString:@"TestSegue"]){ ViewControllerB *controller = (ViewControllerB *)segue.destinationViewController; controller.TestString = @"TEST!";}}