Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hkdorama

macrumors newbie
Original poster
Jul 23, 2010
3
0
I am trying to make a simple application based on 'Utility Application' template.

So, it is supposed to have two view. The 1st view has a picker with a list of poem names, the 2nd view has a simple text view with the text of the selected poem. The picker reads there poem names and contents from a plist file (displaying only the poem names).

What I want to do is to be able to push a button in the first vew, it would read, the selected row in the picker, get the poem contents and then would go to the second view to display it. My problem is: "How to bring the info from the 1st first view to the 2nd?" How to make variables I work with in the 1st view available in the 2nd view?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Sounds more like you have a master-detail-type app, which is commonly based on the Navigation-Based template. You should be able to find plenty of examples of this.
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
Sounds more like you have a master-detail-type app, which is commonly based on the Navigation-Based template. You should be able to find plenty of examples of this.

You are definitely probably right on this, but I can see maybe not wanting to use a table for the source. Maybe a picker view instead...



Just put a public variable in the view controller you are popping up.

@interface myCustomViewController {
NSString *poem;
}
and

@property (nonatomic,retain) NSString *poem;

and

@synthesize poem;



Then when you pop up the view


myCustomViewController *myVc = [[myCustomViewController alloc] initFromNib blablahbla;

myVc.poem = @"This is my poem";

[self pushViewController:myVc animated:blahabla];

[myVc release];



Extremely bad code/pseudocode but it should give you the idea.


Even better just pass the plist ID location from the first to second view controller in this manner and read it straight from the plist when you load the new view.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.