Utility Application

Discussion in 'iOS Programming' started by hkdorama, Jul 23, 2010.

  1. hkdorama macrumors newbie

    Jul 23, 2010
    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?
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    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.
  3. ulbador macrumors 68000


    Feb 11, 2010
    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;

    @property (nonatomic,retain) NSString *poem;


    @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.

Share This Page