PDA

View Full Version : pass information from one object to another




henktade
Feb 26, 2009, 04:36 AM
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



henktade
Feb 26, 2009, 09:35 AM
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:

dejo
Feb 26, 2009, 10:21 AM
Do you have accessor methods for testStr defined in ResponceViewController?

henktade
Feb 26, 2009, 12:16 PM
Do you have accessor methods for testStr defined in ResponceViewController?

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

iphonejudy
Feb 26, 2009, 11:51 PM
[QUOTE=henktade;7172571]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];




I am also having same problem.

I am having a variable storyLink in Rootviewcontroller class.
I want the result of storyLink in Testviewcontroller class.

So i use the below code,
Rootviewcontroller *rootviewcontroller1 = [[Rootviewcontroller alloc]init];
Testviewcontroller *testviewcontroller1 = [[Testviewcontroller alloc]init];
testviewcontroller1.test=rootviewcontroller1.storyLink;
//test is a string variable of Testviewcontroller


NSLog(@"Test View Controller link: %@",test);

In test i got null value.
Can you please tell me the solution?

dejo
Feb 27, 2009, 12:07 AM
Can you please tell me the solution?
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.

iphonejudy
Feb 27, 2009, 12:11 AM
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?

dejo
Feb 27, 2009, 12:20 AM
Do u know the solution of my pblm?
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;

iphonejudy
Feb 27, 2009, 02:16 AM
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;

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

dejo
Feb 27, 2009, 09:05 AM
I think u didnt understand my pblm.
I think you didn't explain it properly then. Sorry.
Anyway i solved it.thanks
Would you mind explaining how you solved it? In case others have the same issue, they can learn from your approach.