-2

I want to pass int or string data from one view to another, please help me

NSUInteger i1 = [array indexOfObject:username];
SSPUserLogedInViewController *logInView = [[SSPUserLogedInViewController alloc] init];
logInView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:logInView animated:YES completion:nil];

I am able to next view but not able to pass the data. Thanks in advance.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
Happy
  • 169
  • 1
  • 4
  • 10

3 Answers3

1
  1. Create a variable for your passing data into your next view.
  2. Using an instance of the next view, access the variable that you have created in next view
  3. assign your value to the variable

For Ex in your case;

  1. Suppose you want to pass the value of an int

    In Next view controller: copy this in **.h** file

@property (assign) int temp;

2. SSPUserLogedInViewController *logInView = [[SSPUserLogedInViewController alloc] init]; >

    logInView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        logInView.temp = <YOUR_VALUE>
        [self presentViewController:logInView animated:YES completion:nil];
  1. In Next view controller: copy this in **.m** file

-(void)viewWillAppear

{

   NSLog(@"My Value = %i",_temp);

}

Enjoy Programming!!

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34
0

Write some function like - (void)doSomeThing:(NSString) data in yourSSPUserLogedInViewController class

and call

[logInView doSomeThing:yourDetails];

after

SSPUserLogedInViewController *logInView = [[SSPUserLogedInViewController alloc] init];

arun.s
  • 1,528
  • 9
  • 12
0

define NSMutableString *string; with property in the SSPUserLogedInViewController class. alloc init in view did load. You can set string like this.

NSString *i1 = [NSString stringWithFormat:@"%@",[array objectAtIndex:indexPath.row]];
SSPUserLogedInViewController *logInView = [[SSPUserLogedInViewController alloc] init];
[logInView.string setString:i1];
logInView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:logInView animated:YES completion:nil];
Rahul
  • 134
  • 6