-5

i am new in ios development .

i have two view controllers .

-(IBAction)clickToview:(id)sender
{
    [self performSegueWithIdentifier:@"1" sender:self];   
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{
    if ([segue.identifier isEqualToString:@"1"]) {
        second *destViewController = segue.destinationViewController;

        destViewController.labA.text=textA.text;  // here i want to set values in labA to labB. in second view .
        destViewController.labB.text=textB.text;

        NSLog(@"labA ");
    }
}

-(void)viewDidLoad
{
    textA.text=@"London ";  // this is my text fields 
    textB.text=@"Dreams ";

    [super viewDidLoad];
}
Chris Loonam
  • 5,735
  • 6
  • 41
  • 63
  • 5
    Believe or not, there several duplicates with **the exact same title.** I can't imagine you couldn't have found at least one of them if you had actually used Google or the site search. –  Oct 19 '13 at 19:44
  • 4
    Also, this has nothing to do with Xcode -- this is a language/algorithm/API question, and it wouldn't be different if you used `make` and `emacs` for writing your iOS application. –  Oct 19 '13 at 19:45
  • 3
    possible duplicate of [passing data between view controllers iOS](http://stackoverflow.com/questions/17536760/passing-data-between-view-controllers-ios) and [Passing Data between View Controllers](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) –  Oct 19 '13 at 19:45
  • @H2CO3 - Wouldn't be that different if you were writing in C++ or C#, for that matter. – Hot Licks Oct 19 '13 at 21:12
  • 1
    @HotLicks This would only be related to Xcode if the question was "how to do it in Interface Builder instead of by writing code" IMO. –  Oct 19 '13 at 21:13

1 Answers1

0

In story Board you can send value one view to another view like Bellow way. Your Implement method did Wrong.

in you Second view-controller you need to define NSString with property and sythsize it.

.h class

@property (nonatomic, strong) NSString *YourString;

.m Class

@synthesize YourString;

Now you can use it like:-

-(IBAction)youMethod:(id)sender
{
    [self performSegueWithIdentifier:@"secondview" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
            if ([segue.identifier isEqualToString:@"secondview"]) {
         secondviewcontroller *controller = segue.destinationViewController
                controller.YourString = @"myValue";
             }

}
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144