lifemoveson
lifemoveson

Reputation: 1691

Is there a way to pass data from one view to modalviewcontroller

I have a view with a UIView and a button. Pressing the button brings up a ModalViewController which is UIView with UITextField in it. I need to pass the string value of NSObject in the UIView to the ModalViewController as a string. On button click I call this:

-(void) editNote{

TextViewController * vc = [(TextViewController *)[TextViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

[self.navigationController presentModalViewController:nav animated:YES];
[vc release];
}   

Normally, on row select we push the data using pushviewcontroller to the next view but after doing lot of google I cannot figure out how to pass the data using presentmodalviewcontroller.

Upvotes: 0

Views: 249

Answers (1)

jtbandes
jtbandes

Reputation: 118651

You could add a property to TextViewController, then just use vc.object = myObject. Or you could make a new init method that takes some more information.

Upvotes: 5

Related Questions