1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

pass information from one object to another

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

  1. macrumors newbie

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

  2. macrumors newbie

    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


    Staff Member

    Do you have accessor methods for testStr defined in ResponceViewController?
  4. macrumors newbie

    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


  6. Moderator


    Staff Member

    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


    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


    Staff Member

    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];
  9. macrumors 6502


    I think u didnt understand my pblm.
    Anyway i solved it.thanks
  10. Moderator


    Staff Member

    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