Reputation: 1576
I have tried to use modal segue in Storyboard to push user data from didSelectRowAtIndexPath and send it to next View Controller .
Here is my code :
In my header file :
@interface ListNearby : UIViewController<UITableViewDataSource,UITableViewDelegate,CLLocationManagerDelegate,UINavigationControllerDelegate,UINavigationBarDelegate>
{
@public
UserDetails *UD;
}
And my .m file :
ResultNearbyList *cell = (ResultNearbyList *) [tableView cellForRowAtIndexPath:indexPath];
self.userFullNameString = cell.userFullName.text;
NSLog(@"FulluserName NextVC = %@",self.userFullNameString);
[self performSegueWithIdentifier:@"sendUserData" sender:self];
And I am preparing segue to pass data to next view controller :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"sendUserData"]) {
UD = (UserDetails *) segue.destinationViewController;
UD.userFullName.text = self.userFullNameString;
NSLog(@"FulluserName Segue = %@",UD.userFullName.text);
NSLog(@"FulluserName Current = %@",self.userFullNameString);
}
}
Segue , showing NextViewController without any problem. The problem is userFullNameString does not sending to NextViewController. I am checking with NSLog , while FulluserName Segue returning null, FulluserName Current returning value that i need.
How can i send that data to the next view controller ?
regards..
Upvotes: 2
Views: 5390
Reputation: 454
declare a property
@property (nonatomic, strong)NSString *userFulName;
in the UserDetails.h
file. In your prepare for segue method
UD.userFulName = self.userFullNameString;
then in the viewDidLoad
of your next view controller(i.e. UserDetails)
userFullName.text = userFulName;
Upvotes: 3