---
title: "Problem in moving value from second view to first view controller in iPhone"  
description: "Problem in moving value from second view to first view controller in iPhone"  
author: "Anonymous User"  
published: 2015-11-23  
updated: 2015-11-24  
canonical: https://www.mindstick.com/forum/33623/problem-in-moving-value-from-second-view-to-first-view-controller-in-iphone  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Problem in moving value from second view to first view controller in iPhone

I have created an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) in iPhone, I have two view [controllers](https://www.mindstick.com/forum/155773/how-asynchronous-controllers-work-in-asp-dot-net-mvc), to move [second](https://answers.mindstick.com/qa/41761/how-did-the-second-industrial-revolution-influence-women-s-roles-in-society) [view controller](https://www.mindstick.com/forum/33709/how-to-use-table-view-controller-with-small-sized-in-ios) I am using segue and set its identifier to 'MainViewController'.

In the second view I am using [Table View](https://www.mindstick.com/forum/33654/send-table-view-cell-value-on-button-action-in-ios) Controller, I want to move first view controller at the time whenever I click on table view cell with cell value. because I am using this cell value in the label of second view controller, but I [am unable](https://answers.mindstick.com/qa/95314/how-do-i-access-a-group-link-in-telegram-if-i-am-unable-to-access-the-link) to display that value in the first view controller.

## This is the code of table view : didSelectedRowAtIndexPath:

```
-(void) tableView:(UITableView *)tableView didSelectedRowAtIndexPath:(NSIndexPath *)indexPath{NSString *key = [[animals allKeys] objectAtIndex:indexPath.section];[self.delegate cellIsClicked:[[animals objectForKey:key] objectAtIndex:indexPath.row]];UIViewController *controller = [self.navigationController.storyboard                               instantiateViewControllerWithIdentifier:@"MainViewController"];[self.navigationController pushViewController:controller animated:YES];}
```

Please help me to [solve this problem](https://answers.mindstick.com/qa/94681/my-google-assistant-shows-completely-different-search-results-from-what-i-ask-how-can-i-solve-this-problem) or tell me what is the problem in my code?\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by Tarun Kumar

You are colling pushViewController: method for navigation to other view [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc),

according to your need this is wrong because pushViewController is used to move next view controller but here our need is to come back to our previous view controller.

so the best solution is that use navigationController's popViewControllerAnimated: method because this method will open the previous veiw controller.\
\
use like this:

```
[self.navigationController popViewControllerAnimated:YES];
```


---

Original Source: https://www.mindstick.com/forum/33623/problem-in-moving-value-from-second-view-to-first-view-controller-in-iphone

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
