0

I have just started developing iphone applications, but now i'm stuck with this problem, my problem is,

how to pick a data from table view and bring it back to previous view.

if you can give me a sample code that would be really appreciated.

Thank in advance, prasad.

Prasad De Zoysa
  • 2,488
  • 2
  • 23
  • 30
  • What kind of data are you selecting and what is your previous view? – Jamie Jun 24 '11 at 04:09
  • Thanks to reply soon - Ok, lets say i have two views First one have button and label, and Second view has the table view contains values "one","two","three" from array. when i press the button on first view its loading the second view which contains the table view, and the problem is here, how can i pick one value and set it to First view label. – Prasad De Zoysa Jun 24 '11 at 04:20

2 Answers2

2

I don't think altering AppDelegate will be a good practice although it will work. You should prefer creating a Model class where you can create a variable and set its value in your table. When you go back to previous view you can use the same variable which contains the selected table value.
Good luck..!!

Community
  • 1
  • 1
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • In this solution i don't have any notifier(Listener), in android we have something like this "onActivityResult" we can send result from a called activity see this http://saigeethamn.blogspot.com/2009/08/android-developer-tutorial-for_31.html , so is there any way equlant to this on iphone development? – Prasad De Zoysa Jun 24 '11 at 04:41
  • how can i notify that i came back? – Prasad De Zoysa Jun 24 '11 at 05:10
  • Okay, i just found it, there is a method called "- (void)viewDidAppear:(BOOL)animated" this will do the trick, and yes thank you very much Nitish for your help. you made my day dude.. and this is the link for controller life cycle that i found - http://eddykudo.com/92 I'm posting these things because some one can found this helpful. – Prasad De Zoysa Jun 24 '11 at 06:01
0

You can make an object in App Delegate class.set its value as the value picked from tableview in the table view class.In the previous class you can make an object of app delegate class & access that particular object whose value was set with the value picked from table view

Swastik
  • 2,415
  • 2
  • 31
  • 61