[Solved] How to pass string value from one .m file to another .m file in iOS [closed]


if you wants to pass data from ViewControlerOne to ViewControllerTwo try these..

do these in ViewControlerOne.h

 @property (nonatomic, strong) NSString *str1;

do these in ViewControllerTwo.h

 @property (nonatomic, strong) NSString *str2;

Synthesize str2 in ViewControllerTwo.m

@interface ViewControllerTwo ()
@end
@implementation ViewControllerTwo
@synthesize str2;

do these in ViewControlerOne.m

 - (void)viewDidLoad
 {
   [super viewDidLoad];

  // Data or string you wants to pass in ViewControllerTwo..
  self.str1 = @"hello world";

 }

on the buttons click event do this..

-(IBAction)ButtonClicked
{ 
  //Navigation on buttons click event from ViewControlerOne to ViewControlerTwo with transferring data or string..
  ViewControllerTwo *objViewTwo=[self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerTwo"];
  objViewTwo.str2=str1;
  [self.navigationController pushViewController: objViewTwo animated:YES];
}

do these in ViewControllerTwo.m

- (void)viewDidLoad
{
 [super viewDidLoad];
  NSLog(@"%@",str2);
}

10

solved How to pass string value from one .m file to another .m file in iOS [closed]