pass information from one object to another

Discussion in 'iPhone/iPad Programming' started by henktade, Feb 26, 2009.

  1. macrumors newbie

    Joined:
    Jan 30, 2009
    #1
    hi guys,

    I am working on one project were one of my view controller connects to a server and parses string(which I done already and which I can see from the log file) then loads a new view. on the new views view controller I want to display the result which is brought from the server. what is the proper way of communicating this information to the other view?

    I have like strings, arrays ...

    tanks
     
  2. thread starter macrumors newbie

    Joined:
    Jan 30, 2009
    #2
    pass information from one object to another(additional info)

    I have a one view called iFetch104ViewController which contains a textField and a button.

    with a click of this button .. I push a navigation bar view controller called ResponceViewController as follows.

    [[self navigationController] pushViewController:[[ResponceViewController alloc] init] animated:YES];

    instead of the above code, I wanted to pass the content of the text field also to the new navigation controller. and I tried the following:


    ResponceViewController *test = [[ResponceViewController alloc]init];

    test.testStr = numberField.text;

    //numberField is a text field on the iFetch104ViewController
    //testStr is a NSString pointer defined in ResponceViewController

    [[self navigationController] pushViewController: test animated:YES];


    so the program crashes every when it execute:

    test.testStr = numberField.text;

    pls help.........:confused:
     
  3. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Do you have accessor methods for testStr defined in ResponceViewController?
     
  4. thread starter macrumors newbie

    Joined:
    Jan 30, 2009
    #4
    missing accessor methods

    that was exactly my problem. I come back to let u guys that I found the problem but tank you dejo for the replay.

    I missed
    @synthesize testStr;

    in ResponceViewController.m
     
  5. macrumors 6502

    iphonejudy

    Joined:
    Sep 12, 2008
    #5
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    So, instead of trying to sort it out in your other thread, you're just gonna come here and post the same question? Not nice.
     
  7. macrumors 6502

    iphonejudy

    Joined:
    Sep 12, 2008
    #7
    I just saw this thread,

    Actualy i try to send personaly to that guy.

    ok.leave it.


    Do u know the solution of my pblm?
     
  8. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    I do. You need to give storyLink a value before you reference it.

    Like so:
    Rootviewcontroller *rootviewcontroller1 = [[Rootviewcontroller alloc]init];
    rootviewcontroller1.storyLink = @"a non-nil value";
    Testviewcontroller *testviewcontroller1 = [[Testviewcontroller alloc]init];
    testviewcontroller1.test=rootviewcontroller1.storyLink;
     
  9. macrumors 6502

    iphonejudy

    Joined:
    Sep 12, 2008
    #9
    I think u didnt understand my pblm.
    Anyway i solved it.thanks
     
  10. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #10
    I think you didn't explain it properly then. Sorry.
    Would you mind explaining how you solved it? In case others have the same issue, they can learn from your approach.
     

Share This Page