1

Possible Duplicate:
Xcode: Storyboard Tabbed Application Passing Data Back and Forth

Basically I have 2 view controllers

1st view controller : contains table view

2nd view controller: contains image view

I want to load the image on 2nd view controller based upon the value selected from table view (from 1st view contrller)

I know I can capture the value of selected cell using following code

NSString *CellVal = [[NSString alloc]init];
CellVal = [exercises objectAtIndex:indexPath.row];

but how do I refer the value of "CellVal" in 2nd View conroller ?

Community
  • 1
  • 1
A K
  • 295
  • 1
  • 4
  • 19
  • You don't need to do `[[NSString alloc] init];` this create an immutable empty string, which is pretty useless. If you are not using ARC then this is also a memory leak. – Paul.s Apr 06 '12 at 22:30
  • You could try this: http://stackoverflow.com/a/9690731/542400 – AMayes Apr 10 '12 at 18:18

1 Answers1

0

Create a NSString property in your second controller. Then, at some point, use something like secondController.stringProperty = cellVal;.

The place where you put the code you posted and that assignment depends on whether you are using xib files or a storyboard. In one case, you would do it where you initialize the second controller from a nib and otherwise you would do it in prepareForSegue: (using the destination controller from the seque).

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57